bucketking657 has uploaded this change for review.

View Change

sgsn_libgtp: pass the real buffer size when encoding the IMEISV

gsm48_encode_bcd_number() was called with max_len 8, which only
worked because it compares max_len against the L octet. A 16-digit
IMEISV needs 9 bytes (L plus 8 octets), so pass 9.

Related: OS#7126
Change-Id: Ied06aa05ee6850ec0df34a51cdce6df12e0b594c
---
M src/sgsn/sgsn_libgtp.c
1 file changed, 2 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/50/44150/1
diff --git a/src/sgsn/sgsn_libgtp.c b/src/sgsn/sgsn_libgtp.c
index b4c24a0..c43dac5 100644
--- a/src/sgsn/sgsn_libgtp.c
+++ b/src/sgsn/sgsn_libgtp.c
@@ -302,7 +302,8 @@
if (mmctx->imei[0] != '\0') {
memset(&pdp->imeisv.v[0], 0, 8);
pdp->imeisv_given = 1;
- gsm48_encode_bcd_number(&pdp->imeisv.v[0], 8, 0, mmctx->imei);
+ /* 9 bytes: the L octet plus 8 octets of IMEISV digits */
+ gsm48_encode_bcd_number(&pdp->imeisv.v[0], 9, 0, mmctx->imei);
pdp->imeisv.l = 8;
memmove(&pdp->imeisv.v[0], &pdp->imeisv.v[1], 8);
}

To view, visit change 44150. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Ied06aa05ee6850ec0df34a51cdce6df12e0b594c
Gerrit-Change-Number: 44150
Gerrit-PatchSet: 1
Gerrit-Owner: bucketking657 <joshuashilts@gmail.com>