From 087369973214d9aef83a3cdf057257cf27e252f4 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 30 Jul 2018 14:06:44 +0200 Subject: [PATCH] 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 --- xen/common/kernel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 06a817e20e..0c64035322 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -193,10 +193,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); } -- 2.39.5