summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2012-12-11 09:42:07 -0800
committerRoland McGrath <[email protected]>2012-12-11 09:42:07 -0800
commit57bd66cabf6e6b9ecf622cdbf350804897a8df58 (patch)
tree28ee93f2aa68c0acf8507e55c383b77eb18a1fb0 /src
parent1d6a435f55ba6ee1568fb6fede6495e37c455cae (diff)
nm: Fix size passed to snprintf for invalid sh_name case.
Signed-off-by: Roland McGrath <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/nm.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9f0c525a..f08ee084 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-11 Roland McGrath <[email protected]>
+
+ * nm.c (show_symbols_sysv): Fix size passed to snprintf for invalid
+ sh_name case.
+ Reported by David Abdurachmanov <[email protected]>.
+
2012-10-16 Mark Wielaard <[email protected]>
* readelf.c (print_ops): DW_OP_skip and DW_OP_bra targets are
diff --git a/src/nm.c b/src/nm.c
index f50da0b1..8a1c57a4 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -769,8 +769,9 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname,
gelf_getshdr (scn, &shdr_mem)->sh_name);
if (unlikely (name == NULL))
{
- name = alloca (sizeof "[invalid sh_name 0x12345678]");
- snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
+ const size_t bufsz = sizeof "[invalid sh_name 0x12345678]"
+ name = alloca (bufsz);
+ snprintf (name, bufsz, "[invalid sh_name %#" PRIx32 "]",
gelf_getshdr (scn, &shdr_mem)->sh_name);
}
scnnames[elf_ndxscn (scn)] = name;