diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-05-29 21:30:20 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-05-29 21:34:12 +0530 |
commit | b937534868c8d7aec3b6d645bf5fd657bbfccd42 (patch) | |
tree | 18936faaea13f35bcaf698f97447752c0e1c4567 /elf/rtld.c | |
parent | d0501bfbe228897c17875fcead8809d017135d6f (diff) | |
download | glibc-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 'elf/rtld.c')
-rw-r--r-- | elf/rtld.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/elf/rtld.c b/elf/rtld.c index 23238ad3fc..91da88cdd1 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1840,10 +1840,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (_dl_name_match_p (GLRO(dl_trace_prelink), l)) GLRO(dl_trace_prelink_map) = l; _dl_printf ("\t%s => %s (0x%0*Zx, 0x%0*Zx)", - l->l_libname->name[0] ? l->l_libname->name - : rtld_progname ?: "<main program>", - l->l_name[0] ? l->l_name - : rtld_progname ?: "<main program>", + DSO_FILENAME (l->l_libname->name), + DSO_FILENAME (l->l_name), (int) sizeof l->l_map_start * 2, (size_t) l->l_map_start, (int) sizeof l->l_addr * 2, @@ -2000,8 +1998,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", first = 0; } - _dl_printf ("\t%s:\n", - map->l_name[0] ? map->l_name : rtld_progname); + _dl_printf ("\t%s:\n", DSO_FILENAME (map->l_name)); while (1) { @@ -2324,7 +2321,7 @@ print_unresolved (int errcode __attribute__ ((unused)), const char *objname, const char *errstring) { if (objname[0] == '\0') - objname = rtld_progname ?: "<main program>"; + objname = RTLD_PROGNAME; _dl_error_printf ("%s (%s)\n", errstring, objname); } @@ -2334,7 +2331,7 @@ static void print_missing_version (int errcode __attribute__ ((unused)), const char *objname, const char *errstring) { - _dl_error_printf ("%s: %s: %s\n", rtld_progname ?: "<program name unknown>", + _dl_error_printf ("%s: %s: %s\n", RTLD_PROGNAME, objname, errstring); } |