[PATCH] osmo-hlr[master]: add error handling to osmo_gsup_configure_wildcard_apn()

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri May 4 14:48:42 UTC 2018


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

add error handling to osmo_gsup_configure_wildcard_apn()

Follow-up to I83d9ef2868bbb01e3f1ddb7920fe735aca172b15 as requested in code review.

Change-Id: Ifcee1e0d275741c1172b208600851861adb13238
---
M src/gsup_server.c
M src/gsup_server.h
M src/hlr.c
M src/luop.c
4 files changed, 20 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/29/8029/1

diff --git a/src/gsup_server.c b/src/gsup_server.c
index 03a6f56..07d4feb 100644
--- a/src/gsup_server.c
+++ b/src/gsup_server.c
@@ -337,15 +337,16 @@
 
 /* Set GSUP message's pdp_infos[0] to a wildcard APN.
  * Use the provided apn_buf to store the produced APN data. This must remain valid until
- * osmo_gsup_encode() is done. */
-void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup,
-				      uint8_t *apn_buf, size_t apn_buf_size)
+ * osmo_gsup_encode() is done. Return 0 if an entry was added, -ENOMEM if the provided buffer is too
+ * small. */
+int osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup,
+				     uint8_t *apn_buf, size_t apn_buf_size)
 {
 	int l;
 
 	l = osmo_apn_from_str(apn_buf, apn_buf_size, "*");
 	if (l <= 0)
-		return;
+		return -ENOMEM;
 
 	gsup->pdp_infos[0].apn_enc = apn_buf;
 	gsup->pdp_infos[0].apn_enc_len = l;
@@ -353,4 +354,6 @@
 	gsup->num_pdp_infos = 1;
 	/* FIXME: use real value: */
 	gsup->pdp_infos[0].context_id = 1;
+
+	return 0;
 }
diff --git a/src/gsup_server.h b/src/gsup_server.h
index b52b783..66c1a9c 100644
--- a/src/gsup_server.h
+++ b/src/gsup_server.h
@@ -53,5 +53,5 @@
 
 void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups);
 
-void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup,
-				      uint8_t *apn_buf, size_t apn_buf_size);
+int osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup,
+				     uint8_t *apn_buf, size_t apn_buf_size);
diff --git a/src/hlr.c b/src/hlr.c
index cab34f0..1c72f45 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -98,7 +98,11 @@
 
 			/* FIXME: PDP infos - use more fine-grained access control
 			   instead of wildcard APN */
-			osmo_gsup_configure_wildcard_apn(&gsup, apn, sizeof(apn));
+			if (osmo_gsup_configure_wildcard_apn(&gsup, apn, sizeof(apn))) {
+				LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode wildcard APN\n",
+				     subscr->imsi);
+				continue;
+			}
 		} else if (co->supports_cs) {
 			gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_CS;
 		} else {
diff --git a/src/luop.c b/src/luop.c
index edf4c51..db7b3c9 100644
--- a/src/luop.c
+++ b/src/luop.c
@@ -242,7 +242,12 @@
 	if (luop->is_ps) {
 		/* FIXME: PDP infos - use more fine-grained access control
 		   instead of wildcard APN */
-		osmo_gsup_configure_wildcard_apn(&gsup, apn, sizeof(apn));
+		if (osmo_gsup_configure_wildcard_apn(&gsup, apn, sizeof(apn))) {
+			LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode wildcard APN\n",
+			     luop->subscr.imsi);
+			lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC);
+			return;
+		}
 	}
 
 	/* Send ISD to new VLR/SGSN */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcee1e0d275741c1172b208600851861adb13238
Gerrit-PatchSet: 1
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list