[libvirt] [PATCH 1/3] storage: Resolve Coverity FORWARD_NULL

John Ferlan jferlan at redhat.com
Wed May 13 16:32:20 UTC 2015


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 at redhat.com>
---
 src/storage/storage_backend_disk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 6394dac..5c2c49a 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -412,7 +412,7 @@ virStorageBackendDiskFindLabel(const char* device)
 
     /* if parted succeeds we have a valid partition table */
     ret = virCommandRun(cmd, NULL);
-    if (ret < 0) {
+    if (ret < 0 && output && error) {
         if (strstr(output, "unrecognised disk label") ||
             strstr(error, "unrecognised disk label")) {
             ret = 1;
-- 
2.1.0




More information about the libvir-list mailing list