]> sourceware.org Git - systemtap.git/commitdiff
stap translator: tolerate NULLs coming from some elfutils string lookups
authorFrank Ch. Eigler <fche@redhat.com>
Sat, 11 Jan 2014 00:51:37 +0000 (19:51 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Sat, 11 Jan 2014 00:54:42 +0000 (19:54 -0500)
It was reported on the mailing list, and privately experienced, that
stap pass-2 crashes could occur due to NULL dwarf_diename or
dwarf_decl_file's being propagated rather far within stap.  This
commit adds protections (of the form ?: "foo") to eliminate the
problem in a few spots.  There may be others; we should not store
so many raw char*'s.

dwflpp.cxx
tapsets.cxx

index 3d87664ff3f7532e10190330da5ed5f09a1bdb56..f7f19a537bad3428a7c16cd806f9ad4cf23f5c0b 100644 (file)
@@ -1743,7 +1743,7 @@ dwflpp::iterate_over_labels (Dwarf_Die *begin_die,
                 {
                   // Get the file/line number for this label
                   int dline;
-                  const char *file = dwarf_decl_file (&die);
+                  const char *file = dwarf_decl_file (&die) ?: "<unknown source>";
                   dwarf_decl_line (&die, &dline);
 
                   vector<Dwarf_Die> scopes = getscopes_die(&die);
@@ -2047,7 +2047,7 @@ dwflpp::function_file (char const ** c)
 {
   assert (function);
   assert (c);
-  *c = dwarf_decl_file (function);
+  *c = dwarf_decl_file (function) ?: "<unknown source>";
 }
 
 
index 4b2fdacfb9a34cf5a67be30a01a36a8f49704b9e..85065933f141871ac31968ba1de6a4c62c276274 100644 (file)
@@ -1689,8 +1689,14 @@ inline_instance_info::operator<(const inline_instance_info& other) const
     return decl_line < other.decl_line;
 
   int cmp = name.compare(other.name);
-  if (!cmp)
-    cmp = strcmp(decl_file, other.decl_file);
+
+  if (!cmp) 
+    {
+      assert (decl_file);
+      assert (other.decl_file);
+      cmp = strcmp(decl_file, other.decl_file);
+    }
+
   return cmp < 0;
 }
 
@@ -4191,8 +4197,7 @@ dwarf_atvar_query::atvar_query_cu (Dwarf_Die * cudie, void * data)
 
   if (! q->e.cu_name.empty())
     {
-      const char *die_name = dwarf_diename(cudie);
-
+      const char *die_name = dwarf_diename(cudie) ?: "";
       if (strcmp(die_name, q->e.cu_name.c_str()) != 0 // Perfect match
           && fnmatch(q->cu_name_pattern.c_str(), die_name, 0) != 0)
         {
@@ -9760,7 +9765,7 @@ tracepoint_derived_probe::build_args(dwflpp&, Dwarf_Die& func_die)
         {
           // build a tracepoint_arg for this parameter
           tracepoint_arg tparg;
-          tparg.name = dwarf_diename(&arg);
+          tparg.name = dwarf_diename(&arg) ?: "";
 
           // read the type of this parameter
           if (!dwarf_attr_die (&arg, DW_AT_type, &tparg.type_die)
This page took 0.058283 seconds and 5 git commands to generate.