summaryrefslogtreecommitdiffstats
path: root/src/gsm
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-07-16 12:03:13 +0200
committerHarald Welte <laforge@gnumonks.org>2011-07-16 12:03:46 +0200
commit4876dcf12b2db9847073fbd2b3e28c4f962bd48a (patch)
tree3a64ab5e99b27920aecc0eb2bc6154646800fc70 /src/gsm
parent2b32215fc331f88502e652bbc4d782950d37f5c5 (diff)
gprs_cipher_core: Fix potential buffer overflows
detected by Smatch
Diffstat (limited to 'src/gsm')
-rw-r--r--src/gsm/gprs_cipher_core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gsm/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c
index 7884be01..b9a22a10 100644
--- a/src/gsm/gprs_cipher_core.c
+++ b/src/gsm/gprs_cipher_core.c
@@ -36,7 +36,7 @@ static struct gprs_cipher_impl *selected_ciphers[_GPRS_ALGO_NUM];
/* register a cipher with the core */
int gprs_cipher_register(struct gprs_cipher_impl *ciph)
{
- if (ciph->algo > ARRAY_SIZE(selected_ciphers))
+ if (ciph->algo >= ARRAY_SIZE(selected_ciphers))
return -ERANGE;
llist_add_tail(&ciph->list, &gprs_ciphers);
@@ -60,7 +60,7 @@ int gprs_cipher_load(const char *path)
int gprs_cipher_run(uint8_t *out, uint16_t len, enum gprs_ciph_algo algo,
uint64_t kc, uint32_t iv, enum gprs_cipher_direction dir)
{
- if (algo > ARRAY_SIZE(selected_ciphers))
+ if (algo >= ARRAY_SIZE(selected_ciphers))
return -ERANGE;
if (!selected_ciphers[algo])
@@ -75,7 +75,7 @@ int gprs_cipher_run(uint8_t *out, uint16_t len, enum gprs_ciph_algo algo,
int gprs_cipher_supported(enum gprs_ciph_algo algo)
{
- if (algo > ARRAY_SIZE(selected_ciphers))
+ if (algo >= ARRAY_SIZE(selected_ciphers))
return -ERANGE;
if (selected_ciphers[algo])