[MERGED] libosmocore[master]: gsm0480: move SS request length check to parse_ss()

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
Wed Jan 17 10:45:43 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: gsm0480: move SS request length check to parse_ss()
......................................................................


gsm0480: move SS request length check to parse_ss()

Change-Id: I8e7ce5bd97f3a8731924264c92afb9a7183937dc
---
M src/gsm/gsm0480.c
1 file changed, 11 insertions(+), 12 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 75388b9..25f97a2 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -255,19 +255,7 @@
 int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len,
 				struct ss_request *req)
 {
-	uint8_t msg_type = hdr->msg_type & 0x3F;
 	int rc = 0;
-
-	/**
-	 * GSM 04.80 Section 2.5 'Release complete' Table 2.5
-	 * payload is optional for 'RELEASE COMPLETE' message
-	 */
-	if (msg_type != GSM0480_MTYPE_RELEASE_COMPLETE) {
-		if (len < sizeof(*hdr) + 2) {
-			LOGP(0, LOGL_DEBUG, "SS Request is too short.\n");
-			return 0;
-		}
-	}
 
 	if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) {
 		req->transaction_id = hdr->proto_discr & 0x70;
@@ -285,6 +273,17 @@
 	int rc = 1;
 	uint8_t msg_type = hdr->msg_type & 0x3F;  /* message-type - section 3.4 */
 
+	/**
+	 * GSM 04.80 Section 2.5 'Release complete' Table 2.5
+	 * payload is optional for 'RELEASE COMPLETE' message
+	 */
+	if (msg_type != GSM0480_MTYPE_RELEASE_COMPLETE) {
+		if (len < 2) {
+			LOGP(0, LOGL_DEBUG, "SS Request is too short.\n");
+			return 0;
+		}
+	}
+
 	/* Table 2.1: Messages for call independent SS control */
 	switch (msg_type) {
 	case GSM0480_MTYPE_RELEASE_COMPLETE:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8e7ce5bd97f3a8731924264c92afb9a7183937dc
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list