提交 44d0db01 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
ACKed-by: NPeter Krempa <pkrempa@redhat.com>
上级 cc9e80c5
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册