[PATCH] libelf: Clear any garbage left in the ar name table.

Mark Wielaard mjw at redhat.com
Mon Dec 15 10:18:29 UTC 2014


Signed-off-by: Mark Wielaard <mjw at redhat.com>
---
 libelf/ChangeLog   | 5 +++++
 libelf/elf_begin.c | 8 ++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index cf168e7..7406509 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-15  Mark Wielaard  <mjw at redhat.com>
+
+	* elf_begin.c (read_long_names): Clear any garbage left in the
+	name table.
+
 2014-12-11  Mark Wielaard  <mjw at redhat.com>
 
 	* elf_begin.c (file_read_elf): Correct ELF64 section offset check.
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 7fb5fa5..c24a364 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -734,10 +734,14 @@ read_long_names (Elf *elf)
       runp = newp;
       while (1)
         {
+	  char *startp = runp;
 	  runp = (char *) memchr (runp, '/', newp + len - runp);
 	  if (runp == NULL)
-	    /* This was the last entry.  */
-	    break;
+	    {
+	      /* This was the last entry.  Clear any left overs.  */
+	      memset (startp, '\0', newp + len - startp);
+	      break;
+	    }
 
 	  /* NUL-terminate the string.  */
 	  *runp = '\0';
-- 
1.8.3.1



More information about the elfutils-devel mailing list