Change in libosmocore[master]: add OSMO_IMSI_BUF_SIZE

Harald Welte gerrit-no-reply at
Sat Apr 13 21:38:58 UTC 2019

Harald Welte has submitted this change and it was merged. ( )

Change subject: add OSMO_IMSI_BUF_SIZE


Various places in our code base figure out how many chars they need to safely
store an IMSI. An IMSI can have a checksum digit, which is not reflected by
GSM23003_IMSI_MAX_DIGITS. And we usually need a terminating \0.

Instead of having a magic +2 repeated every so often, rather define
OSMO_IMSI_BUF_SIZE to contain both checksum digit and nul char, and have the
explanatory comment with it here in libosmocore.

Change-Id: Id11ada4c96b79f7f0ad58185ab7dbf24622fb770
M include/osmocom/gsm/gsup.h
M include/osmocom/gsm/protocol/gsm_23_003.h
2 files changed, 4 insertions(+), 1 deletion(-)

  Harald Welte: Looks good to me, approved
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified

diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 29ea11a..9a583aa 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -232,7 +232,7 @@
 /*! parsed/decoded GSUP protocol message */
 struct osmo_gsup_message {
 	enum osmo_gsup_message_type	message_type;
-	char				imsi[GSM23003_IMSI_MAX_DIGITS+2];
+	char				imsi[OSMO_IMSI_BUF_SIZE];
 	enum gsm48_gmm_cause		cause;
 	enum osmo_gsup_cancel_type	cancel_type;
 	int				pdp_info_compl;
diff --git a/include/osmocom/gsm/protocol/gsm_23_003.h b/include/osmocom/gsm/protocol/gsm_23_003.h
index babd0f4..be1b157 100644
--- a/include/osmocom/gsm/protocol/gsm_23_003.h
+++ b/include/osmocom/gsm/protocol/gsm_23_003.h
@@ -5,6 +5,9 @@
 /* Chapter 2.2 */
 #define GSM23003_IMSI_MAX_DIGITS	15
 #define GSM23003_IMSI_MIN_DIGITS	6
+/*! The char[] buffer size to completely contain an IMSI including the optional checksum digit as well as the
+ * terminating nul character. */
 /* Chapter 2.4 */
 #define GSM23003_TMSI_NUM_BYTES		4
 /* Chapter 2.5 */

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id11ada4c96b79f7f0ad58185ab7dbf24622fb770
Gerrit-Change-Number: 13575
Gerrit-PatchSet: 5
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Harald Welte <laforge at>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list