From ef23f966c538007948e26ea39956fdafd94c9b16 Mon Sep 17 00:00:00 2001 From: FRIGN Date: Tue, 17 Feb 2015 18:18:54 +0100 Subject: [PATCH] Refactor strings(1) loop again fixing a little out-of-bounds write. --- strings.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/strings.c b/strings.c index 4b365f2..cab0fe9 100644 --- a/strings.c +++ b/strings.c @@ -27,17 +27,17 @@ strings(FILE *fp, const char *fname, size_t len) i = 0; continue; } - if (i <= len) { + if (i < len) { rbuf[i++] = r; - if (i < len) - continue; - } else { + continue; + } else if (i > len) { efputrune(&r, stdout, ""); continue; } printf(format, (long)off - i); for (i = 0; i < len; i++) efputrune(rbuf + i, stdout, ""); + efputrune(&r, stdout, ""); i++; } free(rbuf);