]> xenbits.xensource.com Git - xen.git/commitdiff
cmdline: fix parse_boolean() for NULL incoming end pointer
authorJan Beulich <jbeulich@suse.com>
Mon, 30 Jul 2018 12:16:15 +0000 (14:16 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 30 Jul 2018 12:16:15 +0000 (14:16 +0200)
Use the calculated lengths instead of pointers, as 'e' being NULL will
otherwise cause undue parsing failures.

Reported-by: Karl Johnson <karljohnson.it@gmail.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/kernel.c

index 7c01bf22c5faa91e42869237cf39f48dde051dec..0f5e41716ff032239bfbbeebaf5e73d6eacc8d7a 100644 (file)
@@ -195,10 +195,11 @@ int parse_boolean(const char *name, const char *s, const char *e)
         char buf[8];
 
         s += nlen + 1;
-        if ( e <= s || e - s >= ARRAY_SIZE(buf) )
+        slen -= nlen + 1;
+        if ( slen >= ARRAY_SIZE(buf) )
             return -1;
-        memcpy(buf, s, e - s);
-        buf[e - s] = 0;
+        memcpy(buf, s, slen);
+        buf[slen] = 0;
         return parse_bool(buf);
     }