]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
tools/xenstore: fix use after free bug in xenstore_control
authorJuergen Gross <jgross@suse.com>
Mon, 25 Jan 2021 07:23:31 +0000 (08:23 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 25 Jan 2021 15:13:29 +0000 (15:13 +0000)
There is a very unlikely use after free bug and a memory leak in
live_update_start() of xenstore_control. Fix those.

Coverity-Id: 1472399
Fixes: 7f97193e6aa858 ("tools/xenstore: add live update command to xenstore-control")
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/xenstore/xenstore_control.c

index 0c95cf767c2ee98452a264f17205845b07c57872..f6f4626c06568b5d33abab2ee184111083aaaccd 100644 (file)
@@ -43,7 +43,12 @@ static int live_update_start(struct xs_handle *xsh, bool force, unsigned int to)
     if (len < 0)
         return 1;
 
+    ret = strdup("BUSY");
+    if (!ret)
+        return 1;
+
     for (time_start = time(NULL); time(NULL) - time_start < to;) {
+        free(ret);
         ret = xs_control_command(xsh, "live-update", buf, len);
         if (!ret)
             goto err;