Refactor strings(1) loop again
fixing a little out-of-bounds write.
This commit is contained in:
parent
439bf8a157
commit
ef23f966c5
|
@ -27,17 +27,17 @@ strings(FILE *fp, const char *fname, size_t len)
|
||||||
i = 0;
|
i = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i <= len) {
|
if (i < len) {
|
||||||
rbuf[i++] = r;
|
rbuf[i++] = r;
|
||||||
if (i < len)
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else if (i > len) {
|
||||||
efputrune(&r, stdout, "<stdout>");
|
efputrune(&r, stdout, "<stdout>");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf(format, (long)off - i);
|
printf(format, (long)off - i);
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
efputrune(rbuf + i, stdout, "<stdout>");
|
efputrune(rbuf + i, stdout, "<stdout>");
|
||||||
|
efputrune(&r, stdout, "<stdout>");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
free(rbuf);
|
free(rbuf);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user