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 532dec8e31 ("xen:
add an optional string end parameter to parse_bool()")

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Juergen Gross authored and Andrew Cooper committed 2017-08-25 20:11:16 +01:00
1 parent 846be9ef30
commit 803c5a2a42
1 file changed
+3 -1
+3 -1
View File
@@ -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) ||
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.