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

[mini-os master] mini-os: netfront: fix initialization without ip address in xenstore



commit 406592b5e0c593e7e690baae50a70e0e75fea645
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Thu Aug 19 07:30:56 2021 +0200
Commit:     Wei Liu <wl@xxxxxxx>
CommitDate: Tue Aug 31 15:57:40 2021 +0000

    mini-os: netfront: fix initialization without ip address in xenstore
    
    Commit 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling")
    introduced a NULL pointer dereference in the initialization of netfront
    in the case of no IP address being set in Xenstore.
    
    Fix that by testing this condition. At the same time fix a long
    standing bug for the same condition if someone used init_netfront()
    with a non-NULL ip parameter.
    
    Fixes: 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling")
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
 netfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/netfront.c b/netfront.c
index f927e99..dfe065b 100644
--- a/netfront.c
+++ b/netfront.c
@@ -365,7 +365,7 @@ out:
         rawmac[5] = dev->rawmac[5];
        }
     if (ip)
-        *ip = strdup(dev->ip);
+        *ip = dev->ip ? strdup(dev->ip) : NULL;
 
 err:
     return dev;
@@ -527,7 +527,7 @@ done:
         snprintf(path, sizeof(path), "%s/ip", dev->backend);
         xenbus_read(XBT_NIL, path, &dev->ip);
 
-        p = strchr(dev->ip, ' ');
+        p = dev->ip ? strchr(dev->ip, ' ') : NULL;
         if (p) {
             *p++ = '\0';
             dev->mask = p;
--
generated by git-patchbot for /home/xen/git/mini-os.git#master



 


Rackspace

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