Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
xen.26348
xsa407-0l.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xsa407-0l.patch of Package xen.26348
From: Andrew Cooper <andrew.cooper3@citrix.com> Subject: xen/cmdline: Extend parse_boolean() to signal a name match This will help parsing a sub-option which has boolean and non-boolean options available. First, rework 'int val' into 'bool has_neg_prefix'. This inverts it's value, but the resulting logic is far easier to follow. Second, reject anything of the form 'no-$FOO=' which excludes ambiguous constructs such as 'no-$foo=yes' which have never been valid. This just leaves the case where everything is otherwise fine, but parse_bool() can't interpret the provided string. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> (cherry picked from commit 382326cac528dd1eb0d04efd5c05363c453e29f4) --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -171,9 +171,9 @@ int __init parse_bool(const char *s) int parse_boolean(const char *name, const char *s, const char *e) { size_t slen, nlen; - int val = !!strncmp(s, "no-", 3); + bool_t has_neg_prefix = !strncmp(s, "no-", 3); - if ( !val ) + if ( has_neg_prefix ) s += 3; slen = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s); @@ -185,7 +185,11 @@ int parse_boolean(const char *name, cons /* Exact, unadorned name? Result depends on the 'no-' prefix. */ if ( slen == nlen ) - return val; + return !has_neg_prefix; + + /* Inexact match with a 'no-' prefix? Not valid. */ + if ( has_neg_prefix ) + return -1; /* =$SOMETHING? Defer to the regular boolean parsing. */ if ( s[nlen] == '=' ) @@ -194,11 +198,20 @@ int parse_boolean(const char *name, cons s += nlen + 1; slen -= nlen + 1; - if ( slen >= ARRAY_SIZE(buf) ) - return -1; - memcpy(buf, s, slen); - buf[slen] = 0; - return parse_bool(buf); + if ( slen < ARRAY_SIZE(buf) ) + { + int b; + + memcpy(buf, s, slen); + buf[slen] = 0; + b = parse_bool(buf); + + if ( b >= 0 ) + return b; + } + + /* Not a boolean, but the name matched. Signal specially. */ + return -2; } /* Unrecognised. Give up. */ --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -70,7 +70,8 @@ int parse_bool(const char *s); /** * Given a specific name, parses a string of the form: * [no-]$NAME[=...] - * returning 0 or 1 for a recognised boolean, or -1 for an error. + * returning 0 or 1 for a recognised boolean. Returns -1 for general errors, + * and -2 for "not a boolean, but $NAME= matches". */ int parse_boolean(const char *name, const char *s, const char *e);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor