]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Resolve Coverity FORWARD_NULL
authorJohn Ferlan <jferlan@redhat.com>
Wed, 13 May 2015 10:24:50 +0000 (06:24 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Sun, 24 May 2015 11:01:48 +0000 (07:01 -0400)
Coverity points out it's possible for one of the virCommand{Output|Error}*
API's to have not allocated 'output' and/or 'error' in which case the
strstr comparison will cause a NULL deref

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/storage/storage_backend_disk.c

index 6394dac255994be0983312b850bdf6666013f2cb..4dc63d753e1e06ed6b305cad2466ac1f1d72f144 100644 (file)
@@ -413,8 +413,8 @@ virStorageBackendDiskFindLabel(const char* device)
     /* if parted succeeds we have a valid partition table */
     ret = virCommandRun(cmd, NULL);
     if (ret < 0) {
-        if (strstr(output, "unrecognised disk label") ||
-            strstr(error, "unrecognised disk label")) {
+        if ((output && strstr(output, "unrecognised disk label")) ||
+            (error && strstr(error, "unrecognised disk label"))) {
             ret = 1;
         }
     }