]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: avoid null deref on qcowXGetBackingStore
authorAlex Jia <ajia@redhat.com>
Wed, 30 Nov 2011 07:50:44 +0000 (15:50 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 30 Nov 2011 10:05:13 +0000 (11:05 +0100)
Detected by Coverity. the only case is caller passes a NULL to 'format' variable,
then taking 'if (format)' false branch, the function qcow2GetBackingStoreFormat
will directly dereferences the NULL 'format' pointer variable.

Signed-off-by: Alex Jia <ajia@redhat.com>
src/util/storage_file.c

index f33ea74a929e6757e63b01f8d2c4f543132c6acf..ba9cfc51c9063dfe9657f4e7dc87c446197282b6 100644 (file)
@@ -333,7 +333,7 @@ qcowXGetBackingStore(char **res,
      * between the end of the header (QCOW2_HDR_TOTAL_SIZE)
      * and the start of the backingStoreName (offset)
      */
-    if (isQCow2)
+    if (isQCow2 && format)
         qcow2GetBackingStoreFormat(format, buf, buf_size, QCOW2_HDR_TOTAL_SIZE, offset);
 
     return BACKING_STORE_OK;