1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

tests: Fix possible NULL derefs in virErrorTestMsgs

Add guards to avoid calling strchr when @err_noinfo == NULL or
calling virErrorTestMsgFormatInfoOne when @err_info == NULL as
both would fail with a NULL deref.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
John Ferlan 2018-12-17 07:02:26 -05:00
parent cc9e80c593
commit 44d0db011d

View File

@ -74,13 +74,13 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED)
ret = -1;
}
if (strchr(err_noinfo, '%')) {
if (err_noinfo && strchr(err_noinfo, '%')) {
VIR_TEST_VERBOSE("\nerror message id %zu contains formatting characters: '%s'\n",
i, err_noinfo);
ret = -1;
}
if (virErrorTestMsgFormatInfoOne(err_info) < 0)
if (err_info && virErrorTestMsgFormatInfoOne(err_info) < 0)
ret = -1;
}