summaryrefslogtreecommitdiff
path: root/src/libvirt-host.c
diff options
context:
space:
mode:
authorErik Skultety <eskultet@redhat.com>2019-11-18 12:04:16 +0100
committerErik Skultety <eskultet@redhat.com>2019-11-21 18:16:35 +0100
commitd6064e2759a24e0802f363e3a810dc5a7d7ebb15 (patch)
tree7c8e946c810fd94c8473392bc45feccffc601ce7 /src/libvirt-host.c
parentbf2988235cf09c407f39791d446b1ecb99be6c51 (diff)
downloadlibvirt-d6064e2759a24e0802f363e3a810dc5a7d7ebb15.tar.gz
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>
Diffstat (limited to 'src/libvirt-host.c')
-rw-r--r--src/libvirt-host.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
index 221a1b7a43..94ba5a8e80 100644
--- a/src/libvirt-host.c
+++ b/src/libvirt-host.c
@@ -910,7 +910,7 @@ virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems,
virResetLastError();
virCheckConnectReturn(conn, -1);
- virCheckNonNullArgGoto(freeMems, error);
+ virCheckNonNullArrayArgGoto(freeMems, maxCells, error);
virCheckPositiveArgGoto(maxCells, error);
virCheckNonNegativeArgGoto(startCell, error);