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/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/11373 Change subject: gsm0808: allow decoding of zero length speech codec lists. ...................................................................... gsm0808: allow decoding of zero length speech codec lists. 3GPP_TS_48.008, 3.2.2.103 Speech Codec List states the following: "The length indicator (octet 2) is a binary number indicating the absolute length of the contents after the length indicator. The length depends on the number and type of Speech Codec Elements to be included. The minimum length of one Speech Codec Element is 1 octet and the maximum length is 3 octets. The maximum number of Speech Codec Elements within the Speech Codec List is not defined." This clearly refers only to the length of a single speech codec element but not on the overall list. So speech codec lists with length 0 are indeed permitted by the spec. - Remove the assertion that checks on zero length speech codec lists. Change-Id: I1eb1f4466b98bdd26d765b0e4cc690b5e89e9dd6 Related: OS#3657 --- M src/gsm/gsm0808_utils.c M tests/gsm0808/gsm0808_test.c 2 files changed, 23 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/11373/1 diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 886f546..2348105 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -349,9 +349,6 @@ OSMO_ASSERT(msg); OSMO_ASSERT(scl); - /* Empty list */ - OSMO_ASSERT(scl->len >= 1); - msgb_put_u8(msg, GSM0808_IE_SPEECH_CODEC_LIST); tlv_len = msgb_put(msg, 1); old_tail = msg->tail; @@ -384,8 +381,6 @@ OSMO_ASSERT(scl); if (!elem) return -EINVAL; - if (len == 0) - return -EINVAL; memset(scl, 0, sizeof(*scl)); @@ -404,11 +399,6 @@ scl->len = decoded; - /* Empty list */ - if (decoded < 1) { - return -EINVAL; - } - return (int)(elem - old_elem); } diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c index 8cf1cf4..0b2794f 100644 --- a/tests/gsm0808/gsm0808_test.c +++ b/tests/gsm0808/gsm0808_test.c @@ -695,6 +695,28 @@ msgb_free(msg); } +static void test_gsm0808_enc_dec_empty_speech_codec_list() +{ + struct gsm0808_speech_codec_list enc_scl = { + .len = 0, + }; + struct gsm0808_speech_codec_list dec_scl = {}; + struct msgb *msg; + uint8_t rc_enc; + int rc_dec; + + msg = msgb_alloc(1024, "output buffer"); + rc_enc = gsm0808_enc_speech_codec_list(msg, &enc_scl); + OSMO_ASSERT(rc_enc == 2); + + rc_dec = gsm0808_dec_speech_codec_list(&dec_scl, msg->data + 2, msg->len - 2); + OSMO_ASSERT(rc_dec == 0); + + OSMO_ASSERT(memcmp(&enc_scl, &dec_scl, sizeof(enc_scl)) == 0); + + msgb_free(msg); +} + static void test_gsm0808_enc_dec_channel_type() { struct gsm0808_channel_type enc_ct = { @@ -1725,6 +1747,7 @@ test_gsm0808_enc_dec_speech_codec_ext_with_cfg(); test_gsm0808_enc_dec_speech_codec_with_cfg(); test_gsm0808_enc_dec_speech_codec_list(); + test_gsm0808_enc_dec_empty_speech_codec_list(); test_gsm0808_enc_dec_channel_type(); test_gsm0808_enc_dec_encrypt_info(); -- To view, visit https://gerrit.osmocom.org/11373 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I1eb1f4466b98bdd26d765b0e4cc690b5e89e9dd6 Gerrit-Change-Number: 11373 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181016/672d9816/attachment.htm>