]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virmock: Initialize both symbols in VIR_MOCK_REAL_INIT_ALT
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 26 Feb 2019 09:12:05 +0000 (10:12 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 7 Mar 2019 12:40:17 +0000 (13:40 +0100)
commitd7e5baa5a1261877cee5617a1c519c2a0afba75c
tree6ca8090bd683e1ba4c0de1b4dc01a383fc31a908
parent27b6ca7d9c6bd11d90ad5b0291396ce958dd2a08
virmock: Initialize both symbols in VIR_MOCK_REAL_INIT_ALT

It may happen that both symbols are present. Especially when
chaining mocks. For instance if a test is using virpcimock and
then both stat and __xstat would be present in the address space
as virpcimock implements both. Then, if the test would try to use
say virfilewrapper (which again uses VIR_MOCK_REAL_INIT_ALT() to
init real_stat and real___xstat) it would find stat() from
virpcimock and stop there. The virfilewrapper.c:real___xstat
wouldn't be initialized and thus it may result in a segfault.

The reason for segfault is that sys/stat.h may redefine stat() to
call __xstat().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/virmock.h