]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: fix printing hotplug arguments/environment
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 2 Aug 2016 10:49:51 +0000 (12:49 +0200)
committerWei Liu <wei.liu2@citrix.com>
Tue, 2 Aug 2016 16:03:10 +0000 (17:03 +0100)
An OS could decide to not pass any environment variables to hotplug scripts,
and this will trigger a bug in device_hotplug logic, since it expects the
environment array to exist. Allow env to be NULL.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_device.c

index b9a6df28101d463cc77d8a0f75991c72ea7c6074..dbf157d469c4ff98c7942749901906f8b53e0692 100644 (file)
@@ -1130,6 +1130,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
         goto out;
     }
 
+    assert(args != NULL);
     LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
     LOG(DEBUG, "extra args:");
     {
@@ -1140,7 +1141,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
             LOG(DEBUG, "\t%s", arg);
     }
     LOG(DEBUG, "env:");
-    {
+    if (env != NULL) {
         const char *k, *v;
         unsigned int x;