aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-05-04 16:46:47 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-05-04 16:48:26 +0200
commit1b8a1dc00a9965674a93d72f5f042deea546b94a (patch)
treed23046052093f49993c36596008bcb226ed21761
parent9d307ec7ae3dcb8acce91a16eb6ba8fce6e7db10 (diff)
add error handling to osmo_gsup_configure_wildcard_apn()
Follow-up to I83d9ef2868bbb01e3f1ddb7920fe735aca172b15 as requested in code review. Change-Id: Ifcee1e0d275741c1172b208600851861adb13238
-rw-r--r--src/gsup_server.c11
-rw-r--r--src/gsup_server.h4
-rw-r--r--src/hlr.c6
-rw-r--r--src/luop.c7
4 files changed, 20 insertions, 8 deletions
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 @@ void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups)
/* 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 @@ void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup,
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 @@ struct osmo_gsup_server *osmo_gsup_server_create(void *ctx,
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 @@ osmo_hlr_subscriber_update_notify(struct hlr_subscriber *subscr)
/* 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 @@ void lu_op_tx_insert_subscr_data(struct lu_operation *luop)
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 */