sysmobts: The code allowed a out of bounds access to temp_type_str
The array has three elements but check was for > _NUM_TEMP_TYPES (3) so an access at array[3] was possible. It is unlikely to have happened due the usage of enums. Use ARRAY_SIZE and >= on the real array to avoid this problem. Fixes: Coverity CID 1040760
This commit is contained in:
parent
481f14d87f
commit
ed966f0428
|
@ -64,7 +64,7 @@ int sysmobts_temp_get(enum sysmobts_temp_sensor sensor,
|
|||
sensor > SYSMOBTS_TEMP_RF)
|
||||
return -EINVAL;
|
||||
|
||||
if (type > _NUM_TEMP_TYPES)
|
||||
if (type >= ARRAY_SIZE(temp_type_str))
|
||||
return -EINVAL;
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, TEMP_PATH, sensor, temp_type_str[type]);
|
||||
|
|
Loading…
Reference in New Issue