[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen/cmdline: Fix parse_boolean() for unadorned values



commit ac37ec1ddef234eeba6f438c29ff687c64962ebd
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed Jan 31 10:35:52 2018 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Jan 31 10:47:12 2018 +0000

    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@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/kernel.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 19f9bad..5766a0f 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -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;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.