]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
libxc: check for null size file mapping
authorPaul Semel <semelpaul@gmail.com>
Mon, 12 Feb 2018 12:09:15 +0000 (13:09 +0100)
committerWei Liu <wei.liu2@citrix.com>
Tue, 13 Feb 2018 11:45:56 +0000 (11:45 +0000)
Changed the error message when trying to map a null size file.
When doing `xl create` command, we get an Invalid Kernel error
when the file size is greater than zero. For zero length files, we are
falling in the mmap error, and we get an `Invalid parameter` error,
which is not explicit. With this change, we get a `zero length file`
error.

Signed-off-by: Paul Semel <semelpaul@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxc/xc_dom_core.c

index 96e71dd2d9c3d7e676dc548904cb42c93bfc83cf..9bd04cb2d554a5f3075b410514524152be4e18ca 100644 (file)
@@ -225,6 +225,12 @@ void *xc_dom_malloc_filemap(struct xc_dom_image *dom,
                      "tried to map file which is too large");
         goto err;
     }
+    else if ( !*size )
+    {
+        xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
+                     "'%s': zero length file", filename);
+        goto err;
+    }
 
     block = malloc(sizeof(*block));
     if ( block == NULL ) {