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
This commit is contained in:
Philipp Maier 2017-04-28 10:55:05 +02:00 committed by Harald Welte
parent a8a5819155
commit 85a6af213e
1 changed files with 2 additions and 3 deletions

View File

@ -200,11 +200,10 @@ int gsm0808_dec_speech_codec(struct gsm0808_speech_codec *sc,
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++;
len--;