[MERGED] libosmocore[master]: gsm0808: fix control flow issue

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
Mon May 8 07:35:38 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: gsm0808: fix control flow issue
......................................................................


gsm0808: fix control flow issue

Coverity Scan reported a control flow issue in line 206:

CID 166898: Control flow issues (DEADCODE)

The second branch of the if statement can not be reached. The
purpose of the second if branch was to filter out zero length
elements if the header states that it is a non extended speech
codec type. This makes no sense, since the header needs at
least one byte.

This patch removes the second if branch, zero length elements
are catched by the already existing zero length check at the
beginning of the function

Change-Id: I89751fc0d598734c64ef1fdced75b7c4fa77c616
---
M src/gsm/gsm0808_utils.c
1 file changed, 2 insertions(+), 3 deletions(-)

Approvals:
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  Holger Freyther: Looks good to me, approved



diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 054372a..b4bb878 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -200,10 +200,9 @@
 
 	header = *elem;
 
-	/* Malformed elements */
+	/* An extended codec type needs at least two fields,
+	 * bail if the input data length is not sufficient. */
 	if ((header & 0x0F) == 0x0F && len < 2)
-		return -EINVAL;
-	else if ((header & 0x0F) != 0x0F && len < 1)
 		return -EINVAL;
 
 	elem++;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I89751fc0d598734c64ef1fdced75b7c4fa77c616
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list