From: Juergen Gross Date: Fri, 25 Aug 2017 16:11:25 +0000 (+0200) Subject: xen: fix parse_bool() with empty string X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~1560 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=803c5a2a42e7c72a4c848e0f0106a941b758a91f;p=xen.git xen: fix parse_bool() with empty string parse_bool() should return -1 in case it is called with an empty string. In order to allow boolean parameters in the cmdline without specifying a value this case must be handled in _cmdline_parse() by always passing a value string. This fixes commit 532dec8e31174ed450adfd36a4b0b41dec27010d ("xen: add an optional string end parameter to parse_bool()") Reported-by: Andrew Cooper Signed-off-by: Juergen Gross Acked-by: Wei Liu Tested-by: Andrew Cooper Reviewed-by: Andrew Cooper --- diff --git a/xen/common/kernel.c b/xen/common/kernel.c index ec7714961a..71bc547d17 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -114,7 +114,7 @@ static void __init _cmdline_parse(const char *cmdline) simple_strtoll(optval, NULL, 0)); break; case OPT_BOOL: - if ( !parse_bool(optval, NULL) ) + if ( !parse_bool(*optval ? optval : "yes", NULL) ) bool_assert = !bool_assert; assign_integer_param(param, bool_assert); break; @@ -168,6 +168,8 @@ int __init parse_bool(const char *s, const char *e) unsigned int len; len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s); + if ( !len ) + return -1; if ( !strncmp("no", s, len) || !strncmp("off", s, len) ||