t-runner: Fix mem leak with sim keys
PATCH 1/7 t-runner: Fix mem leak with sim keys
Use l_settings_get_value instead of l_settings_get_string to prevent unnecessary memory duplication.
--- tools/test-runner.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/test-runner.c +2 -2
@@ -1961,8 +1961,8 @@ static void create_network_and_run_tests(void *data, void *user_data)HW_CONFIG_SETUP_TMPFS_EXTRAS , ':'); - sim_keys =l_settings_get_string (hw_settings,HW_CONFIG_GROUP_SETUP , -"sim_keys" ); + sim_keys =l_settings_get_value (hw_settings,HW_CONFIG_GROUP_SETUP , +"sim_keys" );if (sim_keys) {if (!strcmp (sim_keys,"ofono" )) {
Signature · 1 line
2.13.6
PATCH 2/7 t-runner: Fix mem leak caused by unclosed dir
--- tools/test-runner.c | 2 ++ 1 file changed, 2 insertions(+)
tools/test-runner.c +2 -0
@@ -2413,6 +2413,8 @@ next:l_free (unit_test_abs_path); } +closedir (d); + exit:l_strfreev (unit_tests); }
Signature · 1 line
2.13.6
PATCH 3/7 t-runner: Fix mem leak caused by python test names
In reply to Tim Kourt--- tools/test-runner.c | 2 ++ 1 file changed, 2 insertions(+)
tools/test-runner.c +2 -0
@@ -1089,6 +1089,8 @@ static bool add_path(const char *path, int level, struct l_queue *config_queue)l_queue_insert (config_queue, entry, insert_test_entry,NULL ); } +l_queue_destroy (py_test_queue, l_free); +closedir (dir);return true; }
Signature · 1 line
2.13.6
PATCH 4/7 t-runner: Fix out-of-bounds write
In reply to Tim Kourt--- tools/test-runner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/test-runner.c +1 -1
@@ -1636,7 +1636,7 @@ static void print_test_status(char *test_name, enum test_status ts, interval_str =l_malloc (int_len);memset (interval_str,' ' , int_len); - interval_str[int_len] ='\0' ; + interval_str[int_len -1 ] ='\0' ;if (interval >0 )sprintf (interval_str,"%.3f sec" , interval);
Signature · 1 line
2.13.6
PATCH 5/7 t-runner: Fix possible assignment of NULL pointer
In reply to Tim Kourt--- tools/test-runner.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/test-runner.c +2 -1
@@ -2674,7 +2674,8 @@ static void run_tests(void) test_action_str = ptr +4 ; ptr =strchr (test_action_str,'\'' ); - *ptr ='\0' ; +if (ptr) + *ptr ='\0' ;if (!strcmp (test_action_str,"virtual" )) native_hw = false;
Signature · 1 line
2.13.6
PATCH 6/7 t-runner: Check for NULL before using strcmp
In reply to Tim Kourt--- tools/test-runner.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/test-runner.c +3 -3
@@ -2957,9 +2957,9 @@ int main(int argc, char *argv[])break ;case 'g' : gdb_opt = optarg; -if (!(!strcmp (gdb_opt,"iwd" ) || - !strcmp (gdb_opt,"hostapd" ) || - !strcmp (gdb_opt,"hwsim" ))) { +if (!gdb_opt || (strcmp (gdb_opt,"iwd" ) && +strcmp (gdb_opt,"hostapd" ) && +strcmp (gdb_opt,"hwsim" ))) {l_error ("--gdb can only be used with iwd" ", hwsim or hostapd" );return EXIT_FAILURE ;
Signature · 1 line
2.13.6
PATCH 7/7 t-runner: Check for errors after opening file
In reply to Tim Kourt--- tools/test-runner.c | 3 +++ 1 file changed, 3 insertions(+)
tools/test-runner.c +3 -0
@@ -524,6 +524,9 @@ static pid_t execute_program(char *argv[], char *envp[], bool wait, S_IRUSR | S_IWUSR); } +if (fd ==-1 ) +exit (EXIT_FAILURE ); +dup2 (fd,1 );dup2 (fd,2 );
Signature · 1 line
2.13.6
Hi Tim,
Quoted 6 lines · Tim Kourt
Use
l_settings_get_valueinstead ofl_settings_get_stringto prevent unnecessary memory duplication.--- tools/test-runner.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
All applied, thanks.
Regards,
-Denis