]> git.ipfire.org Git - thirdparty/libvirt.git/commit
maint: don't leave garbage on early API exit
authorEric Blake <eblake@redhat.com>
Fri, 27 Dec 2013 23:21:32 +0000 (16:21 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 16 Jan 2014 17:45:15 +0000 (10:45 -0700)
commitc05aebfd659979a00ba5046cd549c73af1bb0c74
treeee7643fd85bf3845a0b494b0ffebdbc0441ba015
parentfe89b687a02d1a8e1dce695a67b4f9d2c254d7b9
maint: don't leave garbage on early API exit

Several APIs clear out a user input buffer before attempting to
populate it; but in a few cases we missed this memset if we
detect a reason for an early exit.  Note that these APIs
check for non-NULL arguments, and exit early with an error
message when NULL is passed in; which means that we must be
careful to avoid a NULL deref in order to get to that error
message.  Also, we were inconsistent on the use of
sizeof(virType) vs. sizeof(expression); the latter is more
robust if we ever change the type of the expression (although
such action is unlikely since these types are part of our
public API).

* src/libvirt.c (virDomainGetInfo, virDomainGetBlockInfo)
(virStoragePoolGetInfo, virStorageVolGetInfo)
(virDomainGetJobInfo, virDomainGetBlockJobInfo): Move memset
before any returns.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/libvirt.c