r171 - trunk
Petter Reinholdtsen
pere at moszumanska.debian.org
Tue Jan 14 09:31:14 UTC 2014
Author: pere
Date: 2014-01-14 09:31:14 +0000 (Tue, 14 Jan 2014)
New Revision: 171
Modified:
trunk/chrpath.c
Log:
Try different approach to null terminating, to get rid of Coverity defect report (Coverity CID CID 1153656).
Modified: trunk/chrpath.c
===================================================================
--- trunk/chrpath.c 2014-01-14 09:17:48 UTC (rev 170)
+++ trunk/chrpath.c 2014-01-14 09:31:14 UTC (rev 171)
@@ -157,7 +157,7 @@
return 2;
}
/* +1 for forced trailing null */
- strtab = (char *)malloc(SHDR_O(sh_size)+1);
+ strtab = (char *)calloc(1, SHDR_O(sh_size)+1);
if (strtab == NULL)
{
perror ("allocating memory for string table");
@@ -165,7 +165,6 @@
elf_close(fd);
return 1;
}
- memset(strtab, 0, SHDR_O(sh_size)+1);
if (lseek(fd, SHDR_O(sh_offset), SEEK_SET) == -1)
{
@@ -183,6 +182,7 @@
elf_close(fd);
return 1;
}
+ strtab[SHDR_O(sh_size)] = 0; /* make sure printed string is null terminated */
if ((int)SHDR_O(sh_size) < rpathoff)
{
More information about the Chrpath-commits
mailing list