summaryrefslogtreecommitdiff
path: root/cmd/stackprot_test.c
diff options
context:
space:
mode:
authorJerome Forissier <jerome.forissier@linaro.org>2025-04-29 14:02:18 +0200
committerTom Rini <trini@konsulko.com>2025-05-05 14:18:53 -0600
commit0352eab7d373664c1c01b23154025b83ec0eadca (patch)
tree171ce40adb7b70e79a9516874389958d904d003c /cmd/stackprot_test.c
parent252cd205300c1b9945079c0ae1fe5980ef9dfa56 (diff)
cmd: spawn: reject 0 as an invalid job ID
Job IDs are positive integers greater than 1. 0 is not a valid job ID, therefore fix the comparison in do_wait(). Fixes Coverity defects: *** CID 550296: Control flow issues (NO_EFFECT) /cmd/spawn.c: 172 in do_wait() 166 for (i = 0; i < CONFIG_CMD_SPAWN_NUM_JOBS; i++) 167 if (job[i]) 168 ret = wait_job(i); 169 } else { 170 for (i = 1; i < argc; i++) { 171 id = dectoul(argv[i], NULL); >>> CID 550296: Control flow issues (NO_EFFECT) >>> This less-than-zero comparison of an unsigned value is never true. "id < 0UL". 172 if (id < 0 || id > CONFIG_CMD_SPAWN_NUM_JOBS) 173 return CMD_RET_USAGE; 174 idx = (int)id - 1; 175 ret = wait_job(idx); 176 } 177 } *** CID 550297: Integer handling issues (INTEGER_OVERFLOW) /cmd/spawn.c: 174 in do_wait() 168 ret = wait_job(i); 169 } else { 170 for (i = 1; i < argc; i++) { 171 id = dectoul(argv[i], NULL); 172 if (id < 0 || id > CONFIG_CMD_SPAWN_NUM_JOBS) 173 return CMD_RET_USAGE; >>> CID 550297: Integer handling issues (INTEGER_OVERFLOW) >>> Expression "idx", where "(int)id - 1" is known to be equal to -1, overflows the type of "idx", which is type "unsigned int". 174 idx = (int)id - 1; 175 ret = wait_job(idx); 176 } 177 } Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> CC: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'cmd/stackprot_test.c')
0 files changed, 0 insertions, 0 deletions