tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args()
PATCH 1/1 tests/qtest: Fix potential NULL pointer dereference in qos_build_main_args()
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.
--- tests/qtest/fuzz/qos_fuzz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/qtest/fuzz/qos_fuzz.c +2 -1
@@ -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;
Signature · 1 line
2.19.1
Paolo Bonzini
AppliedQuoted 25 lines · AlexChen
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 <[email protected]>Signed-off-by Alex Chen <[email protected]>--- tests/qtest/fuzz/qos_fuzz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tests/qtest/fuzz/qos_fuzz.c +1
-1@@ -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) {
tests/qtest/fuzz/qos_fuzz.c static GString *qos_build_main_args(void) · line 85
Quoted 7 lines
tests/qtest/fuzz/qos_fuzz.c +1
-0@@ -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
Quoted 6 lines · AlexChen
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 <[email protected]>Signed-off-by Alex Chen <[email protected]>
Thanks
Quoted 27 lines
--- tests/qtest/fuzz/qos_fuzz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tests/qtest/fuzz/qos_fuzz.c +2
-1@@ -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;Signature · 1 line
2.19.1