]> xenbits.xensource.com Git - xen.git/commitdiff
libxc: check blob size before proceeding in xc_dom_check_gzip
authorMatthew Daley <mattjd@gmail.com>
Fri, 14 Jun 2013 15:45:41 +0000 (16:45 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 14 Jun 2013 15:45:41 +0000 (16:45 +0100)
This is part of the fix to a security issue, XSA-55.

Signed-off-by: Matthew Daley <mattjd@gmail.com>
tools/libxc/xc_dom_core.c

index 3cbf9f791e9c05952e61dda676771fdabd11261d..f8d1b08ba82561f8dcb86877edb70e980862dadf 100644 (file)
@@ -284,6 +284,11 @@ size_t xc_dom_check_gzip(xc_interface *xch, void *blob, size_t ziplen)
     unsigned char *gzlen;
     size_t unziplen;
 
+    if ( ziplen < 6 )
+        /* Too small.  We need (i.e. the subsequent code relies on)
+         * 2 bytes for the magic number plus 4 bytes length. */
+        return 0;
+
     if ( strncmp(blob, "\037\213", 2) )
         /* not gzipped */
         return 0;