From: Jan Beulich Date: Mon, 30 Jul 2018 12:16:15 +0000 (+0200) Subject: cmdline: fix parse_boolean() for NULL incoming end pointer X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1fa0ecbb949d62d834d878702a33373571710ce8;p=xen.git cmdline: fix parse_boolean() for NULL incoming end pointer Use the calculated lengths instead of pointers, as 'e' being NULL will otherwise cause undue parsing failures. Reported-by: Karl Johnson Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 7c01bf22c5..0f5e41716f 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -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); }