[PATCH] osmo-msc[master]: GSUP: check osmo_gsup_encode() result

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

Max gerrit-no-reply at lists.osmocom.org
Wed Jan 24 11:50:01 UTC 2018


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

GSUP: check osmo_gsup_encode() result

Check and handle gracefully any error which might appear in
osmo_gsup_encode()

N. B: requires Idaa1deecb6d9e15329bd51867b4f6a03357461f0 in libosmocore.

Change-Id: I4551212011fb0bd898c020a183756ed7a9afb9e5
Related: OS#2864
---
M src/libcommon/gsup_test_client.c
M src/libvlr/vlr.c
2 files changed, 23 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/10/6010/1

diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 5576292..ceac414 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -106,11 +106,16 @@
 	struct imsi_op *io = imsi_op_alloc(g_gc, imsi, IMSI_OP_SAI);
 	struct osmo_gsup_message gsup = {0};
 	struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
+	int rc;
 
 	osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
 	gsup.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
 
-	osmo_gsup_encode(msg, &gsup);
+	rc = osmo_gsup_encode(msg, &gsup);
+	if (rc < 0) {
+		printf("%s: encoding failure (%s)\n", imsi, strerror(-rc));
+		return rc;
+	}
 
 	return gsup_client_send(g_gc, msg);
 }
@@ -121,11 +126,16 @@
 	struct imsi_op *io = imsi_op_alloc(g_gc, imsi, IMSI_OP_LU);
 	struct osmo_gsup_message gsup = {0};
 	struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
+	int rc;
 
 	osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
 	gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
 
-	osmo_gsup_encode(msg, &gsup);
+	rc = osmo_gsup_encode(msg, &gsup);
+	if (rc < 0) {
+		printf("%s: encoding failure (%s)\n", imsi, strerror(-rc));
+		return rc;
+	}
 
 	return gsup_client_send(g_gc, msg);
 }
@@ -134,11 +144,16 @@
 {
 	struct osmo_gsup_message gsup = {0};
 	struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
+	int rc;
 
 	osmo_strlcpy(gsup.imsi, io->imsi, sizeof(gsup.imsi));
 	gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT;
 
-	osmo_gsup_encode(msg, &gsup);
+	rc = osmo_gsup_encode(msg, &gsup);
+	if (rc < 0) {
+		printf("%s: encoding failure (%s)\n", io->imsi, strerror(-rc));
+		return rc;
+	}
 
 	imsi_op_release(io);
 
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index f57df8e..a87c4b2 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -130,7 +130,11 @@
 {
 	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 "

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4551212011fb0bd898c020a183756ed7a9afb9e5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list