* [gentoo-commits] gentoo-alt r1671 - trunk/aix-miscutils/ldd
@ 2010-02-26 12:46 99% Michael Haubenwallner (haubi)
0 siblings, 0 replies; 1+ results
From: Michael Haubenwallner (haubi) @ 2010-02-26 12:46 UTC (permalink / raw
To: gentoo-commits
Author: haubi
Date: 2010-02-26 12:46:08 +0000 (Fri, 26 Feb 2010)
New Revision: 1671
Modified:
trunk/aix-miscutils/ldd/ObjectReader.cc
Log:
fixed off-by-one bug using fgets reading very long lines (runpath)
Modified: trunk/aix-miscutils/ldd/ObjectReader.cc
===================================================================
--- trunk/aix-miscutils/ldd/ObjectReader.cc 2010-02-26 12:45:22 UTC (rev 1670)
+++ trunk/aix-miscutils/ldd/ObjectReader.cc 2010-02-26 12:46:08 UTC (rev 1671)
@@ -21,7 +21,11 @@
line = "";
do {
- linebuf[sizeof(linebuf)-1] = '\0';
+ /* fgets always stores '\0' into the last byte read.
+ * If the byte before the last possible one is either
+ * unchanged or newline, we've read a whole line.
+ */
+ linebuf[sizeof(linebuf)-2] = '\0';
char *read = fgets(linebuf, sizeof(linebuf), file);
if (read == NULL) {
if (feof(file)) {
@@ -30,7 +34,7 @@
throw std::runtime_error(strerror(errno));
}
line += read;
- } while(linebuf[sizeof(linebuf)-1] != '\0');
+ } while(linebuf[sizeof(linebuf)-2] != '\0' && linebuf[sizeof(linebuf)-2] != '\n');
while(line.length() > 0
&& (line[line.length()-1] == '\n' || line[line.length()-1] == '\r')
^ permalink raw reply [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2010-02-26 12:46 99% [gentoo-commits] gentoo-alt r1671 - trunk/aix-miscutils/ldd Michael Haubenwallner (haubi)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox