From 02229369818e82499697adb672749039387e18c1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 14 Sep 2020 13:04:49 -0400 Subject: [PATCH] TT#91003 handle NO_DATA frames from AMR encoder Change-Id: I437ae1a8b2ee440a12caccf8cfae486b90aa00c3 --- lib/codeclib.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/codeclib.c b/lib/codeclib.c index 3be775fcf..83eb129e0 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -1994,9 +1994,20 @@ static int packetizer_amr(AVPacket *pkt, GString *buf, str *output, encoder_t *e unsigned char toc = pkt->data[0]; unsigned char ft = (toc >> 3) & 0xf; - assert(ft <= 13); + if (ft > 15) { + ilog(LOG_WARN | LOG_FLAG_LIMIT, "Received bogus AMR FT %u from encoder", ft); + return -1; + } + if (ft >= 14) { + // NO_DATA or SPEECH_LOST + return -1; + } + assert(ft < AMR_FT_TYPES); // internal bug unsigned int bits = enc->codec_options.amr.bits_per_frame[ft]; - assert(bits != 0); + if (bits == 0) { + ilog(LOG_WARN | LOG_FLAG_LIMIT, "Received bogus AMR FT %u from encoder", ft); + return -1; + } unsigned char *s = (unsigned char *) output->s; // for safe bit shifting