提交 c9679edc 编写于 作者: E Eric Blake

conf: avoid null deref during storage probe

Commit 5c43e2e0 introduced a NULL deref if there is a failure
in virStorageFileGetMetadataInternal.

* src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
Fix error handling.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 0e285a58
...@@ -999,21 +999,21 @@ virStorageFileGetMetadataFromBuf(const char *path, ...@@ -999,21 +999,21 @@ virStorageFileGetMetadataFromBuf(const char *path,
int *backingFormat) int *backingFormat)
{ {
virStorageSourcePtr ret = NULL; virStorageSourcePtr ret = NULL;
virStorageSourcePtr meta = NULL;
if (!(ret = virStorageFileMetadataNew(path, format))) if (!(meta = virStorageFileMetadataNew(path, format)))
return NULL; return NULL;
if (virStorageFileGetMetadataInternal(ret, buf, len, if (virStorageFileGetMetadataInternal(meta, buf, len,
backingFormat) < 0) { backingFormat) < 0)
virStorageSourceFree(ret); goto cleanup;
ret = NULL; if (VIR_STRDUP(*backing, meta->backingStoreRaw) < 0)
} goto cleanup;
if (VIR_STRDUP(*backing, ret->backingStoreRaw) < 0) {
virStorageSourceFree(ret);
ret = NULL;
}
ret = meta;
meta = NULL;
cleanup:
virStorageSourceFree(meta);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册