summaryrefslogtreecommitdiffstats
path: root/src/gsm/ipa.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-08-01 17:29:48 +0200
committerHarald Welte <laforge@gnumonks.org>2018-08-01 17:42:06 +0200
commit5a7740d1dbefcb0116a1936da3f96960250fd849 (patch)
tree1acef76f65c56eb796e414b27caee19de626366a /src/gsm/ipa.c
parent61650d51179a68186716a7a1583ca6d3a195237d (diff)
re-introduce ipa_ccm_idtag_parse_off()
In the previous commit we deprecated ipa_ccm_idtag_parse() but also removed ipa_ccm_idtag_parse_off(), for which I couldn't find any users. However, legacy openbsc.git still uses this function, so let's re-introiduce it in its original form. Change-Id: Ibfe53b04340eb355c8bfb8453a2af1522a4b6baf
Diffstat (limited to 'src/gsm/ipa.c')
-rw-r--r--src/gsm/ipa.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index 3c7c300b..508cc13d 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -100,6 +100,11 @@ const char *ipa_ccm_idtag_name(uint8_t tag)
int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
{
+ return ipa_ccm_idtag_parse_off(dec, buf, len, 0);
+}
+
+int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset)
+{
uint8_t t_len;
uint8_t t_tag;
uint8_t *cur = buf;
@@ -111,6 +116,11 @@ int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
t_len = *cur++;
t_tag = *cur++;
+ if (t_len < len_offset) {
+ LOGP(DLMI, LOGL_ERROR, "minimal offset not included: %d < %d\n", t_len, len_offset);
+ return -EINVAL;
+ }
+
if (t_len > len + 1) {
LOGP(DLMI, LOGL_ERROR, "The tag does not fit: %d > %d\n", t_len, len + 1);
return -EINVAL;
@@ -118,11 +128,11 @@ int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
DEBUGPC(DLMI, "%s='%s' ", ipa_ccm_idtag_name(t_tag), cur);
- dec->lv[t_tag].len = t_len;
+ dec->lv[t_tag].len = t_len - len_offset;
dec->lv[t_tag].val = cur;
- cur += t_len;
- len -= t_len;
+ cur += t_len - len_offset;
+ len -= t_len - len_offset;
}
return 0;
}