[PATCH] libosmo-sccp[master]: osmo_sccp_addr_encode(): Check for more erroneous situations

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Oct 27 13:00:01 UTC 2017


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

osmo_sccp_addr_encode(): Check for more erroneous situations

... and bail out + log an error.

Change-Id: I2a419343e55edad39c59e763d11046c5a439444d
---
M src/sccp2sua.c
1 file changed, 16 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/44/4444/1

diff --git a/src/sccp2sua.c b/src/sccp2sua.c
index ad948c9..e435d9f 100644
--- a/src/sccp2sua.c
+++ b/src/sccp2sua.c
@@ -163,13 +163,15 @@
 		out->gt.gti = OSMO_SCCP_GTI_TT_ONLY;
 		out->gt.tt = *cur++;
 		/* abort, for national use only */
+		LOGP(DLSUA, LOGL_ERROR, "Unsupported national GTI %u\n", sca->global_title_indicator);
 		return -EINVAL;
 	case SCCP_TITLE_IND_TRANS_NUM_ENC:
 		out->presence |= OSMO_SCCP_ADDR_T_GT;
 		out->gt.gti = OSMO_SCCP_GTI_TT_NPL_ENC;
 		out->gt.tt = *cur++;
 		out->gt.npi = *cur >> 4;
-		switch (*cur++ & 0xF) {
+		encoding = *cur++ & 0xF;
+		switch (encoding) {
 		case 1:
 			odd = true;
 			break;
@@ -177,6 +179,7 @@
 			odd = false;
 			break;
 		default:
+			LOGP(DLSUA, LOGL_ERROR, "Unknown GT encoding 0x%x\n", encoding);
 			return -1;
 		}
 		break;
@@ -237,11 +240,20 @@
 
 	if (in->presence & OSMO_SCCP_ADDR_T_PC) {
 		sca->point_code_indicator = 1;
+		/* ITU-T Q.713 states that signalling point codes are 14bit */
+		if (in->pc > 0x3fff) {
+			LOGP(DLSUA, LOGL_ERROR, "Invalid Point Code %u requested\n", in->pc);
+			return -EINVAL;
+		}
 		msgb_put_u16le(msg, in->pc & 0x3ff);
 	}
 
 	if (in->presence & OSMO_SCCP_ADDR_T_SSN) {
 		sca->ssn_indicator = 1;
+		if (in->ssn > 0xff) {
+			LOGP(DLSUA, LOGL_ERROR, "Invalid SSN %u requested\n", in->ssn);
+			return -EINVAL;
+		}
 		msgb_put_u8(msg, in->ssn);
 	}
 
@@ -277,6 +289,9 @@
 		msgb_put_u8(msg, (in->gt.npi << 4) | (odd ? 1 : 2));
 		msgb_put_u8(msg, in->gt.nai & 0x7f);
 		break;
+	default:
+		LOGP(DLSUA, LOGL_ERROR, "Unsupported GTI %u requested\n", in->gt.gti);
+		return -EINVAL;
 	}
 	osmo_isup_party_encode(msg, in->gt.digits);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a419343e55edad39c59e763d11046c5a439444d
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list