From: John Ferlan Date: Mon, 17 Dec 2018 12:02:26 +0000 (-0500) Subject: tests: Fix possible NULL derefs in virErrorTestMsgs X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=44d0db011d9ff54cc63564af9d8039c89e830281;p=libvirt.git 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 ACKed-by: Peter Krempa --- diff --git a/tests/virerrortest.c b/tests/virerrortest.c index eebf259343..b49d1a9135 100644 --- a/tests/virerrortest.c +++ b/tests/virerrortest.c @@ -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; }