]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Fix possible NULL derefs in virErrorTestMsgs
authorJohn Ferlan <jferlan@redhat.com>
Mon, 17 Dec 2018 12:02:26 +0000 (07:02 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 18 Dec 2018 15:12:09 +0000 (10:12 -0500)
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>
tests/virerrortest.c

index eebf2593436226f7a9d51183be79dce4e7dd5766..b49d1a91354f7e63383944af477986d4199ead38 100644 (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;
     }