[PATCH] show_symbols_sysv: Fix incorrect size in snprintf
David Abdurachmanov
David.Abdurachmanov at cern.ch
Tue Dec 11 14:30:55 UTC 2012
A size of a pointer is passed to snprintf forcing it [snprintf] to
truncate the output. size must be sizeof "[invalid sh_name 0x12345678]"
+ 1 (for the terminating null byte "\0").
Signed-off-by: David Abdurachmanov <David.Abdurachmanov at cern.ch>
---
src/nm.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/nm.c b/src/nm.c
index f50da0b..8012b2f 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -770,7 +770,7 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname,
if (unlikely (name == NULL))
{
name = alloca (sizeof "[invalid sh_name 0x12345678]");
- snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
+ snprintf (name, sizeof "[invalid sh_name 0x12345678]" + 1, "[invalid sh_name %#" PRIx32 "]",
gelf_getshdr (scn, &shdr_mem)->sh_name);
}
scnnames[elf_ndxscn (scn)] = name;
--
1.7.4.1
More information about the elfutils-devel
mailing list