diff mbox series

[BlueZ,06/15] test-runner: Fix uninitialised variable usage

Message ID 20240516090340.61417-7-hadess@hadess.net (mailing list archive)
State Accepted
Commit 0640d99ebfaebe7b455a8bd35fefbb9a93485910
Headers show
Series Fix a number of static analysis issues #2 | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 4: B1 Line exceeds max length (94>80): "bluez-5.75/tools/test-runner.c:856:2: var_decl: Declaring variable "argv" without initializer." 5: B1 Line exceeds max length (86>80): "bluez-5.75/tools/test-runner.c:945:2: uninit_use: Using uninitialized value "argv[0]"." 6: B3 Line contains hard tab characters (\t): "943| envp[pos] = NULL;" 8: B3 Line contains hard tab characters (\t): "945|-> printf("Running command %s\n", cmdname ? cmdname : argv[0]);" 10: B3 Line contains hard tab characters (\t): "947| pid = fork();"
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Bastien Nocera May 16, 2024, 9:03 a.m. UTC
Error: UNINIT (CWE-457): [#def72] [important]
bluez-5.75/tools/test-runner.c:856:2: var_decl: Declaring variable "argv" without initializer.
bluez-5.75/tools/test-runner.c:945:2: uninit_use: Using uninitialized value "argv[0]".
943|   	envp[pos] = NULL;
944|
945|-> 	printf("Running command %s\n", cmdname ? cmdname : argv[0]);
946|
947|   	pid = fork();
---
 tools/test-runner.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/tools/test-runner.c b/tools/test-runner.c
index 134e26f9c691..ff5e19825801 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -912,6 +912,11 @@  static void run_command(char *cmdname, char *home)
 		audio_pid[0] = audio_pid[1] = -1;
 
 start_next:
+	if (!run_auto && !cmdname) {
+		fprintf(stderr, "Missing command argument\n");
+		return;
+	}
+
 	if (run_auto) {
 		if (chdir(home + 5) < 0) {
 			perror("Failed to change home test directory");