aboutsummaryrefslogtreecommitdiffstats
path: root/src/libvlr
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-24 12:48:33 +0100
committerHarald Welte <laforge@gnumonks.org>2018-02-08 09:29:50 +0000
commit770fbd20249e526f1da9903c17b667e42a54c876 (patch)
tree4a0b57fc6bd60595e525c560e416eb753a6332a5 /src/libvlr
parent5e60de63ef24a7c3d3b42833a16c85ddf5da11ef (diff)
GSUP: check osmo_gsup_encode() result
Check and handle gracefully any error which might appear in osmo_gsup_encode() - mark corresponding functions with warn_unused_result attribute to make sure this failure is always checked against. Change-Id: I4551212011fb0bd898c020a183756ed7a9afb9e5 Related: OS#2864
Diffstat (limited to 'src/libvlr')
-rw-r--r--src/libvlr/vlr.c26
-rw-r--r--src/libvlr/vlr_auth_fsm.c13
-rw-r--r--src/libvlr/vlr_core.h4
-rw-r--r--src/libvlr/vlr_lu_fsm.c5
4 files changed, 32 insertions, 16 deletions
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index 96627edcd..f73eeb4f8 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -130,7 +130,11 @@ static int vlr_tx_gsup_message(const struct vlr_instance *vlr,
{
struct msgb *msg = gsup_client_msgb_alloc();
- osmo_gsup_encode(msg, gsup_msg);
+ int rc = osmo_gsup_encode(msg, gsup_msg);
+ if (rc < 0) {
+ LOGP(DVLR, LOGL_ERROR, "GSUP encoding failure: %s\n", strerror(-rc));
+ return rc;
+ }
if (!vlr->gsup_client) {
LOGP(DVLR, LOGL_NOTICE, "GSUP link is down, cannot "
@@ -498,8 +502,10 @@ static int vlr_rx_gsup_unknown_imsi(struct vlr_instance *vlr,
struct osmo_gsup_message *gsup_msg)
{
if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg->message_type)) {
- vlr_tx_gsup_error_reply(vlr, gsup_msg,
- GMM_CAUSE_IMSI_UNKNOWN);
+ int rc = vlr_tx_gsup_error_reply(vlr, gsup_msg, GMM_CAUSE_IMSI_UNKNOWN);
+ if (rc < 0)
+ LOGP(DVLR, LOGL_ERROR, "Failed to send error reply for IMSI %s\n", gsup_msg->imsi);
+
LOGP(DVLR, LOGL_NOTICE,
"Unknown IMSI %s, discarding GSUP request "
"of type 0x%02x\n",
@@ -775,7 +781,7 @@ static int vlr_subscr_handle_cancel_req(struct vlr_subscr *vsub,
struct osmo_gsup_message *gsup_msg)
{
struct osmo_gsup_message gsup_reply = {0};
- int is_update_procedure = !gsup_msg->cancel_type ||
+ int rc, is_update_procedure = !gsup_msg->cancel_type ||
gsup_msg->cancel_type == OSMO_GSUP_CANCEL_TYPE_UPDATE;
LOGVSUBP(LOGL_INFO, vsub, "Cancelling MS subscriber (%s)\n",
@@ -783,11 +789,11 @@ static int vlr_subscr_handle_cancel_req(struct vlr_subscr *vsub,
"update procedure" : "subscription withdraw");
gsup_reply.message_type = OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT;
- vlr_subscr_tx_gsup_message(vsub, &gsup_reply);
+ rc = vlr_subscr_tx_gsup_message(vsub, &gsup_reply);
vlr_subscr_cancel(vsub, gsup_msg->cause);
- return 0;
+ return rc;
}
/* Incoming handler for GSUP from HLR.
@@ -812,9 +818,11 @@ int vlr_gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg)
if (!gsup.imsi[0]) {
LOGP(DVLR, LOGL_ERROR, "Missing IMSI in GSUP message\n");
- if (OSMO_GSUP_IS_MSGT_REQUEST(gsup.message_type))
- vlr_tx_gsup_error_reply(vlr, &gsup,
- GMM_CAUSE_INV_MAND_INFO);
+ if (OSMO_GSUP_IS_MSGT_REQUEST(gsup.message_type)) {
+ rc = vlr_tx_gsup_error_reply(vlr, &gsup, GMM_CAUSE_INV_MAND_INFO);
+ if (rc < 0)
+ LOGP(DVLR, LOGL_ERROR, "Failed to send error reply for IMSI %s\n", gsup.imsi);
+ }
rc = -GMM_CAUSE_INV_MAND_INFO;
goto msgb_free_and_return;
}
diff --git a/src/libvlr/vlr_auth_fsm.c b/src/libvlr/vlr_auth_fsm.c
index d14ae8efb..51e22c9dc 100644
--- a/src/libvlr/vlr_auth_fsm.c
+++ b/src/libvlr/vlr_auth_fsm.c
@@ -207,8 +207,11 @@ static void auth_fsm_onenter_failed(struct osmo_fsm_inst *fi, uint32_t prev_stat
/* If authentication hasn't even started, e.g. the HLR sent no auth
* info, then we also don't need to tell the HLR about an auth failure.
*/
- if (afp->auth_requested)
- vlr_subscr_tx_auth_fail_rep(vsub);
+ if (afp->auth_requested) {
+ int rc = vlr_subscr_tx_auth_fail_rep(vsub);
+ if (rc < 0)
+ LOGVSUBP(LOGL_ERROR, vsub, "Failed to communicate AUTH failure to HLR\n");
+ }
}
/* Terminate the Auth FSM Instance and notify parent */
@@ -281,7 +284,9 @@ static void auth_fsm_needs_auth(struct osmo_fsm_inst *fi, uint32_t event, void *
/* Check if we have vectors available */
if (!vlr_subscr_has_auth_tuple(vsub, afp->auth_tuple_max_reuse_count)) {
/* Obtain_Authentication_Sets_VLR */
- vlr_subscr_req_sai(vsub, NULL, NULL);
+ int rc = vlr_subscr_req_sai(vsub, NULL, NULL);
+ if (rc < 0)
+ LOGPFSM(fi, "Failed to request Authentication Sets from VLR\n");
osmo_fsm_inst_state_chg(fi, VLR_SUB_AS_NEEDS_AUTH_WAIT_AI,
GSM_29002_TIMER_M, 0);
} else {
@@ -374,7 +379,7 @@ static void auth_fsm_wait_auth_resp(struct osmo_fsm_inst *fi, uint32_t event,
case VLR_AUTH_E_MS_AUTH_FAIL:
if (par->auts) {
/* First failure, start re-sync attempt */
- vlr_subscr_req_sai(vsub, par->auts,
+ rc = vlr_subscr_req_sai(vsub, par->auts,
vsub->last_tuple->vec.rand);
osmo_fsm_inst_state_chg(fi,
VLR_SUB_AS_NEEDS_AUTH_WAIT_SAI_RESYNC,
diff --git a/src/libvlr/vlr_core.h b/src/libvlr/vlr_core.h
index bf6314d92..a6585be28 100644
--- a/src/libvlr/vlr_core.h
+++ b/src/libvlr/vlr_core.h
@@ -5,9 +5,9 @@
struct osmo_gsup_message;
const char *vlr_subscr_name(struct vlr_subscr *vsub);
-int vlr_subscr_req_lu(struct vlr_subscr *vsub, bool is_ps);
+int vlr_subscr_req_lu(struct vlr_subscr *vsub, bool is_ps) __attribute__((warn_unused_result));
int vlr_subscr_req_sai(struct vlr_subscr *vsub, const uint8_t *auts,
- const uint8_t *auts_rand);
+ const uint8_t *auts_rand) __attribute__((warn_unused_result));
struct vlr_subscr *vlr_subscr_alloc(struct vlr_instance *vlr);
void vlr_subscr_update_tuples(struct vlr_subscr *vsub,
const struct osmo_gsup_message *gsup);
diff --git a/src/libvlr/vlr_lu_fsm.c b/src/libvlr/vlr_lu_fsm.c
index 6c8b53adb..0ac5b9ad1 100644
--- a/src/libvlr/vlr_lu_fsm.c
+++ b/src/libvlr/vlr_lu_fsm.c
@@ -72,11 +72,14 @@ static void upd_hlr_vlr_fsm_init(struct osmo_fsm_inst *fi, uint32_t event,
void *data)
{
struct vlr_subscr *vsub = fi->priv;
+ int rc;
OSMO_ASSERT(event == UPD_HLR_VLR_E_START);
/* Send UpdateLocation to HLR */
- vlr_subscr_req_lu(vsub, vsub->vlr->cfg.is_ps);
+ rc = vlr_subscr_req_lu(vsub, vsub->vlr->cfg.is_ps);
+ if (rc < 0)
+ LOGPFSML(fi, LOGL_ERROR, "Failed to send UpdateLocation to HLR\n");
osmo_fsm_inst_state_chg(fi, UPD_HLR_VLR_S_WAIT_FOR_DATA,
LU_TIMEOUT_LONG, 0);
}