Change in osmo-sgsn[master]: fix bogus error check in gprs_sndcp_comp_create()

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

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Thu Nov 15 13:03:04 UTC 2018


Stefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/11730 )

Change subject: fix bogus error check in gprs_sndcp_comp_create()
......................................................................

fix bogus error check in gprs_sndcp_comp_create()

The function gprs_sndcp_get_compression_class() returns -EINVAL
upon error, not -1, so an existing assertion would never trigger.

Instead, check for the values we want first (PROTOCOL_COMP or
DATA_COMP) and assert(false) in case the returned value doesn't
match either of these.

Found by: Neels

Change-Id: I8444c1ed052707c76a979fb06cb018ac678defa7
---
M src/gprs/gprs_sndcp_comp.c
1 file changed, 4 insertions(+), 3 deletions(-)

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



diff --git a/src/gprs/gprs_sndcp_comp.c b/src/gprs/gprs_sndcp_comp.c
index 60b15b9..3e02603 100644
--- a/src/gprs/gprs_sndcp_comp.c
+++ b/src/gprs/gprs_sndcp_comp.c
@@ -92,19 +92,20 @@
 	 * (Protocol or Data compresson ?) */
 	comp_entity->compclass = gprs_sndcp_get_compression_class(comp_field);
 
-	OSMO_ASSERT(comp_entity->compclass != -1);
-
 	/* Create an algorithm specific compression context */
 	if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION) {
 		if (gprs_sndcp_pcomp_init(ctx, comp_entity, comp_field) != 0) {
 			talloc_free(comp_entity);
 			comp_entity = NULL;
 		}
-	} else {
+	} else if (comp_entity->compclass == SNDCP_XID_DATA_COMPRESSION) {
 		if (gprs_sndcp_dcomp_init(ctx, comp_entity, comp_field) != 0) {
 			talloc_free(comp_entity);
 			comp_entity = NULL;
 		}
+	} else {
+		/* comp_field is somehow invalid */
+		OSMO_ASSERT(false);
 	}
 
 	/* Bail on failure */

-- 
To view, visit https://gerrit.osmocom.org/11730
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8444c1ed052707c76a979fb06cb018ac678defa7
Gerrit-Change-Number: 11730
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181115/12138f71/attachment.htm>


More information about the gerrit-log mailing list