[libvirt] [PATCH 1/2] qemu: blockPeek: Fix filling of the return buffer

Peter Krempa pkrempa at redhat.com
Tue Sep 19 06:39:27 UTC 2017


On Mon, Sep 18, 2017 at 12:29:57 -0500, Eric Blake wrote:
> On 09/18/2017 09:11 AM, Peter Krempa wrote:
> > 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
> > ---
> >  src/qemu/qemu_driver.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> > index e1a0dd553..93a1c6061 100644
> > --- a/src/qemu/qemu_driver.c
> > +++ b/src/qemu/qemu_driver.c
> > @@ -11415,6 +11415,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
> >      virQEMUDriverPtr driver = dom->conn->privateData;
> >      virDomainDiskDefPtr disk = NULL;
> >      virDomainObjPtr vm;
> > +    char *tmpbuf = NULL;
> >      int ret = -1;
> > 
> >      virCheckFlags(0, -1);
> > @@ -11444,12 +11445,15 @@ qemuDomainBlockPeek(virDomainPtr dom,
> >      if (virStorageFileRead(disk->src, offset, size, buffer) < 0)
> >          goto cleanup;
> > 
> > +    memcpy(buffer, tmpbuf, size);
> 
> Umm, where is tmpbuf actually set to a non-null pointer? Shouldn't the
> virStorageFileRead() call also be updated?

Oh, I messed up splitting of the two changes in this series. I obviously
tested only both patches.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170919/876c1edb/attachment-0001.sig>


More information about the libvir-list mailing list