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 <jfer...@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to