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:
Holger Hans Peter Freyther 2013-07-03 10:48:29 +02:00
parent 481f14d87f
commit ed966f0428
1 changed files with 1 additions and 1 deletions

View File

@ -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]);