qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args()
@ 2020-11-03 14:53 AlexChen
  2020-11-03 15:00 ` Paolo Bonzini
  2020-11-03 15:08 ` Alexander Bulekov
  0 siblings, 2 replies; 3+ messages in thread
From: AlexChen @ 2020-11-03 14:53 UTC (permalink / raw)
  To: alxndr, Paolo Bonzini, bsd, stefanha, thuth, lvivier
  Cc: QEMU, zhang.zhanghailiang

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;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args()
  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
  2020-11-03 15:08 ` Alexander Bulekov
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-11-03 15:00 UTC (permalink / raw)
  To: AlexChen, alxndr, bsd, stefanha, thuth, lvivier; +Cc: QEMU, zhang.zhanghailiang

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args()
  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
@ 2020-11-03 15:08 ` Alexander Bulekov
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Bulekov @ 2020-11-03 15:08 UTC (permalink / raw)
  To: AlexChen
  Cc: lvivier, thuth, zhang.zhanghailiang, QEMU, bsd, stefanha,
	Paolo Bonzini

On 201103 2253, 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>

Reviewed-by: Alexander Bulekov <alxndr@bu.edu>

Thanks

> ---
>  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;
> -- 
> 2.19.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-03 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2020-11-03 15:08 ` Alexander Bulekov

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).