This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] show_symbols_sysv: Fix incorrect size in snprintf


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@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]