pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32436 )
(
6 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: layer23: Use OSMO_IMSI_BUF_SIZE from libosmocore ......................................................................
layer23: Use OSMO_IMSI_BUF_SIZE from libosmocore
Note: GSM_IMSI_LENGTH was 16 octets, and OSMO_IMSI_BUF_SIZE is 17 octets. Probably a bug in old osmocom-bb code since that code predates the one in libosmocore.
Change-Id: I295444bb3b75ed236ea4af5563d9a9c9e590cab7 --- M src/host/layer23/include/osmocom/bb/common/settings.h M src/host/layer23/include/osmocom/bb/common/subscriber.h M src/host/layer23/src/common/subscriber.c 3 files changed, 20 insertions(+), 6 deletions(-)
Approvals: osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h b/src/host/layer23/include/osmocom/bb/common/settings.h index 5e04894..60b9df1 100644 --- a/src/host/layer23/include/osmocom/bb/common/settings.h +++ b/src/host/layer23/include/osmocom/bb/common/settings.h @@ -3,6 +3,7 @@
#include <osmocom/core/utils.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/gsm/protocol/gsm_23_003.h>
struct osmocom_ms; struct osmobb_apn; @@ -77,14 +78,14 @@
/* SIM */ int sim_type; /* selects card on power on */ - char emergency_imsi[16]; + char emergency_imsi[OSMO_IMSI_BUF_SIZE];
/* SMS */ char sms_sca[22]; bool store_sms;
/* test card simulator settings */ - char test_imsi[16]; + char test_imsi[OSMO_IMSI_BUF_SIZE]; uint32_t test_tmsi; uint8_t test_ki_type; uint8_t test_ki[16]; /* 128 bit max */ diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h index 3aacbda..3de8cda 100644 --- a/src/host/layer23/include/osmocom/bb/common/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h @@ -1,6 +1,8 @@ #ifndef _SUBSCRIBER_H #define _SUBSCRIBER_H
+#include <osmocom/gsm/protocol/gsm_23_003.h> + /* GSM 04.08 4.1.2.2 SIM update status */ #define GSM_SIM_U0_NULL 0 #define GSM_SIM_U1_UPDATED 1 @@ -18,8 +20,6 @@ uint8_t cause; };
-#define GSM_IMSI_LENGTH 16 - #define GSM_SIM_IS_READER(type) \ (type == GSM_SIM_TYPE_L1PHY || type == GSM_SIM_TYPE_SAP)
@@ -40,7 +40,7 @@ uint8_t imsi_attached; /* attached state */
/* IMSI & co */ - char imsi[GSM_IMSI_LENGTH]; + char imsi[OSMO_IMSI_BUF_SIZE]; char msisdn[31]; /* may include access codes */ char iccid[21]; /* 20 + termination */
diff --git a/src/host/layer23/src/common/subscriber.c b/src/host/layer23/src/common/subscriber.c index 90d6a78..c75c3ce 100644 --- a/src/host/layer23/src/common/subscriber.c +++ b/src/host/layer23/src/common/subscriber.c @@ -229,7 +229,7 @@
/* decode IMSI, skip first digit (parity) */ imsi = sim_decode_bcd(data + 1, length); - if (strlen(imsi) - 1 > GSM_IMSI_LENGTH - 1 || strlen(imsi) - 1 < 6) { + if (strlen(imsi) >= OSMO_IMSI_BUF_SIZE || strlen(imsi) - 1 < 6) { LOGP(DMM, LOGL_NOTICE, "IMSI invalid length = %zu\n", strlen(imsi) - 1); return -EINVAL;