sensor_shell: fix assertion due to NULL pointer deref
The `SENSOR_CHAN_VSHUNT` was added in #60717 but was never added to the `sensor_channel_name[SENSOR_CHAN_COMMON_COUNT]` table. Since the length of `sensor_channel_name` is fixed to `SENSOR_CHAN_COMMON_COUNT`, this means that the index at `SENSOR_CHAN_VSHUNT` points to `NULL`. When we use the `sensor get` command for anything bigger than `SENSOR_CHAN_VSHUNT`, we will deref that `NULL` pointer when we do `strcmp` in the for-loop of `parse_named_int`. Fix this by defining `SENSOR_CHAN_VSHUNT` in the table. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is contained in:
parent
26f3073b9a
commit
e879cd0502
1 changed files with 1 additions and 0 deletions
|
@ -78,6 +78,7 @@ static const char *sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
|
|||
[SENSOR_CHAN_VOC] = "voc",
|
||||
[SENSOR_CHAN_GAS_RES] = "gas_resistance",
|
||||
[SENSOR_CHAN_VOLTAGE] = "voltage",
|
||||
[SENSOR_CHAN_VSHUNT] = "vshunt",
|
||||
[SENSOR_CHAN_CURRENT] = "current",
|
||||
[SENSOR_CHAN_POWER] = "power",
|
||||
[SENSOR_CHAN_RESISTANCE] = "resistance",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue