[PATCH] openbsc[master]: Sanity fixes for gsm0408_dispatch(): rc, assertions

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Sep 16 01:23:19 UTC 2016


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

Sanity fixes for gsm0408_dispatch(): rc, assertions

gsm0408_dispatch() is the main entry point for receiving data from the BSC/RNC
level, so make sure callers pass valid pointers before using them all the way
down the code path (related to CID#93769, a fix before this was refactored).

For unknown/unimplemented packet discriminators, make sure to return error
codes.

Change-Id: Ieec39c74a53ef4dfa971dd935c8c9aa60fef58c1
---
M openbsc/src/libmsc/gsm_04_08.c
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/55/855/1

diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 680ce93..95994a4 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -3664,6 +3664,9 @@
 	uint8_t pdisc = gsm48_hdr_pdisc(gh);
 	int rc = 0;
 
+	OSMO_ASSERT(conn);
+	OSMO_ASSERT(msg);
+
 	LOGP(DRLL, LOGL_DEBUG, "Dispatching 04.08 message, pdisc=%d\n", pdisc);
 	if (silent_call_reroute(conn, msg))
 		return silent_call_rx(conn, msg);
@@ -3687,6 +3690,7 @@
 	case GSM48_PDISC_SM_GPRS:
 		LOGP(DRLL, LOGL_NOTICE, "Unimplemented "
 			"GSM 04.08 discriminator 0x%02x\n", pdisc);
+		rc = -ENOTSUP;
 		break;
 	case GSM48_PDISC_NC_SS:
 		release_anchor(conn);
@@ -3695,6 +3699,7 @@
 	default:
 		LOGP(DRLL, LOGL_NOTICE, "Unknown "
 			"GSM 04.08 discriminator 0x%02x\n", pdisc);
+		rc = -EINVAL;
 		break;
 	}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieec39c74a53ef4dfa971dd935c8c9aa60fef58c1
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list