[hackers] [sbase] Add explicit boundary to loop in readrune() || FRIGN

From: <git_AT_suckless.org>
Date: Sun, 1 Feb 2015 11:20:54 +0100 (CET)

commit 38da7cce4bb3534cea4488157e08ac80987885bf
Author: FRIGN <dev_AT_frign.de>
Date: Sun Feb 1 04:20:02 2015 +0100

    Add explicit boundary to loop in readrune()
    
    You never know what could happen. Better have a "blind" read than
    a segmentation fault.

diff --git a/libutf/readrune.c b/libutf/readrune.c
index 8bab478..3fda9ef 100644
--- a/libutf/readrune.c
+++ b/libutf/readrune.c
_AT_@ -27,7 +27,7 @@ readrune(const char *file, FILE *fp, Rune *r)
         }
 
         buf[0] = c;
- for (i = 1; ;) {
+ for (i = 1; i < UTFmax; ) {
                 if ((c = fgetc(fp)) == EOF) {
                         if (ferror(fp)) {
                                 fprintf(stderr, "%s: read error: %s\n",
Received on Sun Feb 01 2015 - 11:20:54 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 01 2015 - 11:24:15 CET