xen/cmdline: Fix parse_boolean() for unadorned values

A command line such as "cpuid=no-ibrsb,no-stibp" tickles a bug in
parse_boolean() because the separating comma fails the NUL case.

Instead, check for slen == nlen which accounts for the boundary (if any)
passed via the 'e' parameter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2018-01-31 10:47:12 +00:00
1 parent 16a31ca735
commit ac37ec1dde
1 file changed
+10 -6
+10 -6
View File
@@ -259,12 +259,16 @@ int parse_boolean(const char *name, const char *s, const char *e)
if ( slen < nlen || strncmp(s, name, nlen) )
return -1;
switch ( s[nlen] )
{
case '\0': return val;
case '=': return parse_bool(&s[nlen + 1], e);
default: return -1;
}
/* Exact, unadorned name? Result depends on the 'no-' prefix. */
if ( slen == nlen )
return val;
/* =$SOMETHING? Defer to the regular boolean parsing. */
if ( s[nlen] == '=' )
return parse_bool(&s[nlen + 1], e);
/* Unrecognised. Give up. */
return -1;
}
unsigned int tainted;
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.