From: Paolo Bonzini <pbonzini@redhat.com>
To: AlexChen <alex.chen@huawei.com>,
alxndr@bu.edu, bsd@redhat.com, stefanha@redhat.com,
thuth@redhat.com, lvivier@redhat.com
Cc: QEMU <qemu-devel@nongnu.org>, zhang.zhanghailiang@huawei.com
Subject: Re: [PATCH] tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args()
Date: Tue, 3 Nov 2020 16:00:47 +0100 [thread overview]
Message-ID: <a46040dc-14f3-955c-3d8d-1aca9ad29f80@redhat.com> (raw)
In-Reply-To: <5FA16ED5.4000203@huawei.com>
On 03/11/20 15:53, AlexChen wrote:
> In qos_build_main_args(), the pointer 'path' is dereferenced before
> checking it is valid, which may lead to NULL pointer dereference.
> So move the assignment to 'cmd_line' after checking 'path' is valid.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Alex Chen <alex.chen@huawei.com>
> ---
> tests/qtest/fuzz/qos_fuzz.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c
> index b943577b8c..cee1a2a60f 100644
> --- a/tests/qtest/fuzz/qos_fuzz.c
> +++ b/tests/qtest/fuzz/qos_fuzz.c
> @@ -70,7 +70,7 @@ static GString *qos_build_main_args(void)
> {
> char **path = fuzz_path_vec;
> QOSGraphNode *test_node;
> - GString *cmd_line = g_string_new(path[0]);
> + GString *cmd_line;
> void *test_arg;
>
> if (!path) {
> @@ -79,6 +79,7 @@ static GString *qos_build_main_args(void)
> }
>
> /* Before test */
> + cmd_line = g_string_new(path[0]);
> current_path = path;
> test_node = qos_graph_get_node(path[(g_strv_length(path) - 1)]);
> test_arg = test_node->u.test.arg;
>
Queued, thanks.
Paolo
next prev parent reply other threads:[~2020-11-03 15:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 14:53 [PATCH] tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args() AlexChen
2020-11-03 15:00 ` Paolo Bonzini [this message]
2020-11-03 15:08 ` Alexander Bulekov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a46040dc-14f3-955c-3d8d-1aca9ad29f80@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.chen@huawei.com \
--cc=alxndr@bu.edu \
--cc=bsd@redhat.com \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=zhang.zhanghailiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).