]> xenbits.xensource.com Git - libvirt.git/commit
libvirt-<module>: Check caller-provided buffers to be NULL with size > 0
authorErik Skultety <eskultet@redhat.com>
Mon, 18 Nov 2019 11:04:16 +0000 (12:04 +0100)
committerErik Skultety <eskultet@redhat.com>
Thu, 21 Nov 2019 17:16:35 +0000 (18:16 +0100)
commitd6064e2759a24e0802f363e3a810dc5a7d7ebb15
tree7c8e946c810fd94c8473392bc45feccffc601ce7
parentbf2988235cf09c407f39791d446b1ecb99be6c51
libvirt-<module>: Check caller-provided buffers to be NULL with size > 0

Pre-Glib era which used malloc allowed the size of the client-side
buffers to be declared as 0, because malloc documents that it can either
return 0 or a unique pointer on 0 size allocations.
With glib this doesn't work anymore, because glib documents that for
such allocation requests NULL is always returned which results in an
error in our public API checks server-side.
This patch complements the fix in the RPC layer by explicitly erroring
out on the following combination of args used by our legacy APIs (their
moder equivalents don't suffer from this):

function(caller-allocated-array, size, ...) {
    if (!caller-allocated-array && size > 0)
        return error;
}

treating everything else as a valid input and potentially let that fail
on the server-side rather than client-side.

https://bugzilla.redhat.com/show_bug.cgi?id=1772842

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/internal.h
src/libvirt-domain-snapshot.c
src/libvirt-domain.c
src/libvirt-host.c
src/libvirt-interface.c
src/libvirt-network.c
src/libvirt-nodedev.c
src/libvirt-nwfilter.c
src/libvirt-secret.c
src/libvirt-storage.c