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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

patchbot
commit 3686d0963ed2dd18825e6c108056b3a58bbcd1fb
Author:     Jan Beulich <[hidden email]>
AuthorDate: Mon Jul 30 12:00:59 2018 +0200
Commit:     Jan Beulich <[hidden email]>
CommitDate: Mon Jul 30 12:00:59 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 <[hidden email]>
    Signed-off-by: Jan Beulich <[hidden email]>
---
 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 ed49c62a46..75567274fa 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -191,10 +191,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.8

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog