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

[xen master] ns16550: harden name/value pair parsing



commit b27d3b45c75cf378f06ed72758c034a5d0f8d560
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Apr 7 13:53:49 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Apr 7 13:53:49 2026 +0200

    ns16550: harden name/value pair parsing
    
    strsep(), unless passed a 1st argument which itself points at a NULL
    pointer, won't return NULL. Instead if the separator(s) looked for isn't
    found, that pointed-to field would be updated to hold NULL. Hence the
    important check in get_token() is for token to be non-NULL after the call
    (which get_token()'s callers rely upon), while the checking of param_name
    is left there just in case.
    
    Fixes: 97fd49a7e074 ("ns16550: add support for UART parameters to be 
specifed with name-value pairs")
    Reported-by: Kamil Frankowicz <kamil.frankowicz@xxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/drivers/char/ns16550.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index b23e85a3c6..0339d321bd 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1443,7 +1443,7 @@ static enum __init serial_param_type get_token(char 
*token, char **value)
     unsigned int i;
 
     param_name = strsep(&token, "=");
-    if ( param_name == NULL )
+    if ( !param_name || !token )
         return num_serial_params;
 
     /* Linear search for the parameter. */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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