]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
nm: Fix size passed to snprintf for invalid sh_name case.
authorRoland McGrath <roland@hack.frob.com>
Tue, 11 Dec 2012 17:42:07 +0000 (09:42 -0800)
committerRoland McGrath <roland@hack.frob.com>
Tue, 11 Dec 2012 17:42:07 +0000 (09:42 -0800)
Signed-off-by: Roland McGrath <roland@hack.frob.com>
src/ChangeLog
src/nm.c

index 9f0c525acfdc00666eeda569526aa03bd6c6f332..f08ee084855fd4c7f94498ab4dbdf08c444abe87 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-11  Roland McGrath  <roland@hack.frob.com>
+
+       * nm.c (show_symbols_sysv): Fix size passed to snprintf for invalid
+       sh_name case.
+       Reported by David Abdurachmanov <David.Abdurachmanov@cern.ch>.
+
 2012-10-16  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (print_ops): DW_OP_skip and DW_OP_bra targets are
index f50da0b1e81644d68e0ad82760d879fd9ed8360b..8a1c57a49d2ae19ed89b4250c508027c4c0b7434 100644 (file)
--- 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;