cli: reject a negative sensor list start index

`sensor list <start>` parsed start with _atoi(), whose uint32_t goes
negative as an int: a start of 4294967295 is -1 and 2147483648 is
INT_MIN. Both passed the `start >= end` guard, so the loop asked the
sensor manager for a negative index and passed the NULL it returned
to "%s=%s", undefined behaviour that picolibc happens to print as
"(null)". Rejecting a negative start closes it: ZephyrSensorManager
has one setting, so only index 0 is ever requested.

The same defect as meshcore-dev/MeshCore#3433.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pieter Viljoen
2026-10-05 12:14:47 -07:00
co-authored by Claude Opus 5.5
parent cdd6cc6300
commit 8190b4018e
+1 -1
View File
@@ -589,7 +589,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
if (strlen(command) > 11) {
start = _atoi(command + 12);
}
if (start >= end) {
if (start < 0 || start >= end) {
strcpy(reply, "no custom var");
} else {
snprintf(dp, CLI_REPLY_SIZE - (dp - reply), "%d vars\n", end);