[PATCH] openbsc[master]: sgsn: fix problem with leading-zero-IMSIs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Tue Feb 28 16:08:01 UTC 2017


Review at  https://gerrit.osmocom.org/1938

sgsn: fix problem with leading-zero-IMSIs

When the IMSI ACL is maintained via the VTY, users may enter IMSIs
without leading zeros. Especially in test environments, where
MCC=001 and MNC=01 is common, it is likely that someone enters the
corresponding IMSI (001010000000001) without the two zeros at the
beginning.

This patch fixes the problem by sanitizing the IMSI, eventually
missing zeros in the beginning will be automatically added.

Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517
---
M openbsc/src/gprs/sgsn_vty.c
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/38/1938/1

diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index 6c8b640..9fd5a3d 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -586,9 +586,13 @@
 	"Remove IMSI from ACL\n"
 	"IMSI of subscriber\n")
 {
+	char imsi_sanitized[16];
 	const char *op = argv[0];
-	const char *imsi = argv[1];
+	const char *imsi = imsi_sanitized;
 	int rc;
+
+	/* Sanitize IMSI */
+	sprintf(imsi_sanitized,"%015li", atol(argv[1]));
 
 	if (!strcmp(op, "add"))
 		rc = sgsn_acl_add(imsi, g_cfg);
@@ -597,7 +601,6 @@
 
 	if (rc < 0) {
 		vty_out(vty, "%% unable to %s ACL%s", op, VTY_NEWLINE);
-
 		return CMD_WARNING;
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/1938
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list