Browse Source

Fix segfault in apache (#185)

Fix segfault in apache.
Don Porter 6 years ago
parent
commit
b00f5c4c86
1 changed files with 5 additions and 2 deletions
  1. 5 2
      LibOS/shim/src/elf/shim_rtld.c

+ 5 - 2
LibOS/shim/src/elf/shim_rtld.c

@@ -700,9 +700,12 @@ postmap:
 
     /* When we profile the SONAME might be needed for something else but
        loading.  Add it right away.  */
-    if (l->l_info[DT_STRTAB] && l->l_info[DT_SONAME])
-        l->l_soname = (char *) (D_PTR (l->l_info[DT_STRTAB])
+    if (l->l_info[DT_STRTAB] && l->l_info[DT_SONAME]) {
+        /* DEP 3/12/18: This string is not stable; copy it. */
+        char * tmp = (char *) (D_PTR (l->l_info[DT_STRTAB])
                               + D_PTR (l->l_info[DT_SONAME]));
+        l->l_soname = remalloc(tmp, strlen(tmp) + 1);
+    }
 
     if (l->l_phdr == NULL) {
         /* The program header is not contained in any of the segments.