aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2013-05-29 21:30:20 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2013-05-29 21:34:12 +0530
commitb937534868c8d7aec3b6d645bf5fd657bbfccd42 (patch)
tree18936faaea13f35bcaf698f97447752c0e1c4567 /sysdeps
parentd0501bfbe228897c17875fcead8809d017135d6f (diff)
downloadglibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.tar
glibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.tar.gz
glibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.tar.bz2
glibc-b937534868c8d7aec3b6d645bf5fd657bbfccd42.zip
Avoid crashing in LD_DEBUG when program name is unavailable
Resolves: #15465 The program name may be unavailable if the user application tampers with argc and argv[]. Some parts of the dynamic linker caters for this while others don't, so this patch consolidates the check and fallback into a single macro and updates all users.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/ldsodefs.h5
-rw-r--r--sysdeps/i386/dl-machine.h6
-rw-r--r--sysdeps/powerpc/powerpc32/dl-machine.c3
-rw-r--r--sysdeps/powerpc/powerpc64/dl-machine.h3
-rw-r--r--sysdeps/s390/s390-32/dl-machine.h3
-rw-r--r--sysdeps/s390/s390-64/dl-machine.h3
-rw-r--r--sysdeps/sh/dl-machine.h3
-rw-r--r--sysdeps/sparc/sparc32/dl-machine.h3
-rw-r--r--sysdeps/sparc/sparc64/dl-machine.h3
-rw-r--r--sysdeps/x86_64/dl-machine.h4
10 files changed, 15 insertions, 21 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 3f44809802..cb17204259 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -128,6 +128,11 @@ typedef struct link_map *lookup_t;
| ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4) \
| ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4)))
+/* The filename itself, or the main program name, if available. */
+#define DSO_FILENAME(name) ((name)[0] ? (name) \
+ : (rtld_progname ?: "<main program>"))
+
+#define RTLD_PROGNAME (rtld_progname ?: "<program name unknown>")
/* For the version handling we need an array with only names and their
hash values. */
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 0b4c46736d..b6fc8051e5 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -464,8 +464,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
@@ -610,8 +609,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.c b/sysdeps/powerpc/powerpc32/dl-machine.c
index bd42fdf7d5..c75c173b35 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.c
+++ b/sysdeps/powerpc/powerpc32/dl-machine.c
@@ -510,8 +510,7 @@ __process_machine_rela (struct link_map *map,
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr, (char *) finaladdr, MIN (sym->st_size,
refsym->st_size));
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index 14ade21d96..059fdafd53 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -734,8 +734,7 @@ elf_machine_rela (struct link_map *map,
_dl_error_printf ("%s: Symbol `%s' has different size" \
" in shared object," \
" consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (char *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
index 544f843d87..aa8f1a5f14 100644
--- a/sysdeps/s390/s390-32/dl-machine.h
+++ b/sysdeps/s390/s390-32/dl-machine.h
@@ -383,8 +383,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
strtab = (const char *) D_PTR(map,l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
index 0504eb6b7a..32f7a2cb2f 100644
--- a/sysdeps/s390/s390-64/dl-machine.h
+++ b/sysdeps/s390/s390-64/dl-machine.h
@@ -361,8 +361,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
strtab = (const char *) D_PTR (map,l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
index 25cd52a8e3..da7b9c1a06 100644
--- a/sysdeps/sh/dl-machine.h
+++ b/sysdeps/sh/dl-machine.h
@@ -336,8 +336,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index 71e120f643..30f9246785 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -411,8 +411,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index d6d20c7294..3bce5d182f 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -436,8 +436,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
_dl_error_printf ("\
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ RTLD_PROGNAME, strtab + refsym->st_name);
}
memcpy (reloc_addr_arg, (void *) value,
MIN (sym->st_size, refsym->st_size));
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 4768c69544..116fed1b07 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -430,9 +430,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
# endif
strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
- _dl_error_printf (fmt,
- rtld_progname ?: "<program name unknown>",
- strtab + refsym->st_name);
+ _dl_error_printf (fmt, RTLD_PROGNAME, strtab + refsym->st_name);
}
break;
# ifndef RESOLVE_CONFLICT_FIND_MAP