r170 - trunk

Petter Reinholdtsen pere at moszumanska.debian.org
Tue Jan 14 09:17:48 UTC 2014


Author: pere
Date: 2014-01-14 09:17:48 +0000 (Tue, 14 Jan 2014)
New Revision: 170

Modified:
   trunk/chrpath.c
Log:
Ensure printed rpath is always null terminated (Coverity CID 1153656).

Modified: trunk/chrpath.c
===================================================================
--- trunk/chrpath.c	2014-01-14 09:16:41 UTC (rev 169)
+++ trunk/chrpath.c	2014-01-14 09:17:48 UTC (rev 170)
@@ -156,7 +156,8 @@
       elf_close(fd);
       return 2;
     }
-  strtab = (char *)malloc(SHDR_O(sh_size));
+  /* +1 for forced trailing null */
+  strtab = (char *)malloc(SHDR_O(sh_size)+1);
   if (strtab == NULL)
     {
       perror ("allocating memory for string table");
@@ -164,7 +165,7 @@
       elf_close(fd);
       return 1;
     }
-  memset(strtab, 0, SHDR_O(sh_size));
+  memset(strtab, 0, SHDR_O(sh_size)+1);
 
   if (lseek(fd, SHDR_O(sh_offset), SEEK_SET) == -1)
   {




More information about the Chrpath-commits mailing list