diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-04-06 13:49:40 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-04-06 18:55:14 +0200 |
commit | 8f4cd86904b702041e44a491a45becd0fec9758c (patch) | |
tree | 72ba91cfad2c30cecca7ca73804a0d3ddaec225e /src/ranap_common.c | |
parent | e5c5525baebac7e784f801f91fc12fca700a3c4e (diff) |
ranap_parse_lai(): add LAC size check, and log all parse errors
Diffstat (limited to 'src/ranap_common.c')
-rw-r--r-- | src/ranap_common.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ranap_common.c b/src/ranap_common.c index 7cbf1f9..57f2e83 100644 --- a/src/ranap_common.c +++ b/src/ranap_common.c @@ -499,8 +499,11 @@ int ranap_parse_lai(struct gprs_ra_id *ra_id, const RANAP_LAI_t *lai) uint8_t *ptr = lai->pLMNidentity.buf; /* TS 25.413 9.2.3.55 */ - if (lai->pLMNidentity.size != 3) + if (lai->pLMNidentity.size != 3) { + LOGP(DRANAP, LOGL_ERROR, "Invalid PLMN Identity size:" + " should be 3, is %d\n", lai->pLMNidentity.size); return -1; + } ra_id->mcc = (ptr[0] & 0xF) * 100 + (ptr[0] >> 4) * 10 + @@ -510,11 +513,20 @@ int ranap_parse_lai(struct gprs_ra_id *ra_id, const RANAP_LAI_t *lai) if ((ptr[1] >> 4) != 0xF) ra_id->mnc += (ptr[1] >> 4) * 100; + if (lai->lAC.size != 2) { + LOGP(DRANAP, LOGL_ERROR, "Invalid LAC size:" + " should be 2, is %d\n", lai->lAC.size); + return -1; + } + ra_id->lac = asn1str_to_u16(&lai->lAC); /* TS 25.413 9.2.3.6 */ - if (ra_id->lac == 0 || ra_id->lac == 0xfffe) + if (ra_id->lac == 0 || ra_id->lac == 0xfffe) { + LOGP(DRANAP, LOGL_ERROR, "Invalid LAC: 0x%hx\n", + ra_id->lac); return -1; + } return 0; } |