[hackers] [sbase] Refactor strings(1) loop again || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 17 Feb 2015 18:33:39 +0100 (CET)

commit 3f066f238fd36a92e65ffe3696ff5e7a5d26b04f
Author: FRIGN <dev_AT_frign.de>
Date: Tue Feb 17 18:18:54 2015 +0100

    Refactor strings(1) loop again
    
    fixing a little out-of-bounds write.

diff --git a/strings.c b/strings.c
index 4b365f2..cab0fe9 100644
--- a/strings.c
+++ b/strings.c
_AT_@ -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, "<stdout>");
                         continue;
                 }
                 printf(format, (long)off - i);
                 for (i = 0; i < len; i++)
                         efputrune(rbuf + i, stdout, "<stdout>");
+ efputrune(&r, stdout, "<stdout>");
                 i++;
         }
         free(rbuf);
Received on Tue Feb 17 2015 - 18:33:39 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 17 2015 - 18:36:16 CET