aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-03 10:48:29 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-09 15:46:50 +0200
commited966f0428065c758917e5255b5d0859cd5b99c5 (patch)
treec7a2c3d95b4663e0e2ae25550e036afed06e0eea
parent481f14d87fad24a9b6c99df702904cf4219c9c8c (diff)
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
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_misc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_misc.c b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
index 266eb00b..fdded439 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_misc.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_misc.c
@@ -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]);