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

[Xen-changelog] [xen stable-4.9] cmdline: fix parse_boolean() for NULL incoming end pointer



commit 036006fb22a3e36048d136ef0cdbaa938fc483a7
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jul 30 11:47:06 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 30 11:47:06 2018 +0200

    cmdline: fix parse_boolean() for NULL incoming end pointer
    
    Use the calculated lengths instead of pointers, as 'e' being NULL will
    otherwise cause undue parsing failures.
    
    Reported-by: Karl Johnson <karljohnson.it@xxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/common/kernel.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 71f5b8d62f..6b408f4572 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -209,10 +209,11 @@ int parse_boolean(const char *name, const char *s, const 
char *e)
         char buf[8];
 
         s += nlen + 1;
-        if ( e <= s || e - s >= ARRAY_SIZE(buf) )
+        slen -= nlen + 1;
+        if ( slen >= ARRAY_SIZE(buf) )
             return -1;
-        memcpy(buf, s, e - s);
-        buf[e - s] = 0;
+        memcpy(buf, s, slen);
+        buf[slen] = 0;
         return parse_bool(buf);
     }
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.9

_______________________________________________
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®.