mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: blockPeek: Fix filling of the return buffer
Commit 3956af495e broke the blockPeek API since virStorageFileRead allocates a return buffer and fills it with the data, while the API fills a user-provided buffer. This did not get caught by the compiler since the API prototype uses a 'void *'. Fix it by transferring the data from the allocated buffer to the user provided buffer. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1491217
This commit is contained in:
parent
eb3fc2dd2a
commit
f767d53dbe
@ -11415,6 +11415,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
|
|||||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
virDomainDiskDefPtr disk = NULL;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
|
char *tmpbuf = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
@ -11441,15 +11442,18 @@ qemuDomainBlockPeek(virDomainPtr dom,
|
|||||||
if (qemuDomainStorageFileInit(driver, vm, disk->src) < 0)
|
if (qemuDomainStorageFileInit(driver, vm, disk->src) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virStorageFileRead(disk->src, offset, size, buffer) < 0)
|
if (virStorageFileRead(disk->src, offset, size, &tmpbuf) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
memcpy(buffer, tmpbuf, size);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (disk)
|
if (disk)
|
||||||
virStorageFileDeinit(disk->src);
|
virStorageFileDeinit(disk->src);
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
|
VIR_FREE(tmpbuf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user