]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
libxl: add initializers for libxl__domid_history
authorPaul Durrant <pdurrant@amazon.com>
Wed, 26 Feb 2020 13:12:13 +0000 (13:12 +0000)
committerWei Liu <wl@xen.org>
Wed, 26 Feb 2020 21:48:39 +0000 (21:48 +0000)
This patch fixes Coverity issue CID 1459006 (Insecure data handling
(INTEGER_OVERFLOW)).

The problem is that the error paths for libxl__mark_domid_recent() and
libxl__is_domid_recent() check the 'f' field in struct libxl__domid_history
when it may not have been initialized.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Acked-by: Wei Liu <wl@xen.org>
tools/libxl/libxl_domain.c

index 8937aeb260de87675cb45a5956ba059f246437a1..41d08394f3c8e33d54afb7142df9eae582d47eaa 100644 (file)
@@ -1390,7 +1390,7 @@ static int libxl__read_recent(libxl__gc *gc,
 static int libxl__mark_domid_recent(libxl__gc *gc, uint32_t domid)
 {
     libxl__flock *lock;
-    struct libxl__domid_history ctxt;
+    struct libxl__domid_history ctxt = {};
     char *new;
     FILE *nf = NULL;
     int r, rc;
@@ -1461,7 +1461,7 @@ out:
 
 int libxl__is_domid_recent(libxl__gc *gc, uint32_t domid, bool *recent)
 {
-    struct libxl__domid_history ctxt;
+    struct libxl__domid_history ctxt = {};
     int rc;
 
     rc = libxl__open_domid_history(gc, &ctxt);