mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
storage: avoid null deref on qemu-img failure
Detected by Coverity. Only possible if qemu-img gives bogus output, but we might as well be robust. * src/storage/storage_backend.c (virStorageBackendQEMUImgBackingFormat): Check for strstr failure.
This commit is contained in:
parent
2dee896593
commit
c04beb5d3a
@ -631,8 +631,13 @@ static int virStorageBackendQEMUImgBackingFormat(const char *qemuimg)
|
||||
if (virCommandRun(cmd, &exitstatus) < 0)
|
||||
goto cleanup;
|
||||
|
||||
start = strstr(help, " create ");
|
||||
end = strstr(start, "\n");
|
||||
if ((start = strstr(help, " create ")) == NULL ||
|
||||
(end = strstr(start, "\n")) == NULL) {
|
||||
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unable to parse qemu-img output '%s'"),
|
||||
help);
|
||||
goto cleanup;
|
||||
}
|
||||
if (((tmp = strstr(start, "-F fmt")) && tmp < end) ||
|
||||
((tmp = strstr(start, "-F backing_fmt")) && tmp < end))
|
||||
ret = QEMU_IMG_BACKING_FORMAT_FLAG;
|
||||
|
Loading…
Reference in New Issue
Block a user