]> git.ozlabs.org Git - ccan/commitdiff
ciniparser: Add a check that len remains within bounds.
authorAndreas Schlick <schlick@lavabit.com>
Tue, 26 Apr 2011 15:07:49 +0000 (17:07 +0200)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 27 Apr 2011 05:43:02 +0000 (15:13 +0930)
If the line is made solely of whitespaces, they get removed and we end up with len
set to -1. Therefore we need an additional check to avoid dereferencing line[-1].

ccan/ciniparser/ciniparser.c

index d28c15817e10de530ef43e05744d56106ae0fef9..2b60e409bd7ac7259d2e5245fd457e8087ed7472 100644 (file)
@@ -423,7 +423,7 @@ dictionary *ciniparser_load(const char *ininame)
                }
 
                /* Detect multi-line */
                }
 
                /* Detect multi-line */
-               if (line[len] == '\\') {
+               if (len >= 0 && line[len] == '\\') {
                        /* Multi-line value */
                        last = len;
                        continue;
                        /* Multi-line value */
                        last = len;
                        continue;