diff mbox

[v2] libxl: fix printing hotplug arguments/environment

Message ID 1470134991-17569-1-git-send-email-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné Aug. 2, 2016, 10:49 a.m. UTC
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>
---
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
Changes since v1:
 - Fix commit message
 - Only allow env to be NULL.
---
 tools/libxl/libxl_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Wei Liu Aug. 2, 2016, 10:51 a.m. UTC | #1
On Tue, Aug 02, 2016 at 12:49:51PM +0200, Roger Pau Monne wrote:
> 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>

> ---
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> ---
> Changes since v1:
>  - Fix commit message
>  - Only allow env to be NULL.
> ---
>  tools/libxl/libxl_device.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
> index b9a6df2..dbf157d 100644
> --- a/tools/libxl/libxl_device.c
> +++ b/tools/libxl/libxl_device.c
> @@ -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;
>  
> -- 
> 2.7.4 (Apple Git-66)
>
diff mbox

Patch

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index b9a6df2..dbf157d 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -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;