From 4a643d98c388727e73aebbe626a7379c6fddbbbe Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Fri, 14 Sep 2018 16:27:03 -0400
Subject: [PATCH] Fixes packet parsing for 16-bit CPUs

Without that change, a very long (> 682 ms) illegal packet could trigger
a wrap-around in the test and be accepted as valid.

Only 16-bit architectures (e.g. TI C5x) were affected.
---
 src/opus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/opus.c b/src/opus.c
index cdbd13a11..538b5ea74 100644
--- a/src/opus.c
+++ b/src/opus.c
@@ -252,7 +252,7 @@ int opus_packet_parse_impl(const unsigned char *data, opus_int32 len,
       /* Number of frames encoded in bits 0 to 5 */
       ch = *data++;
       count = ch&0x3F;
-      if (count <= 0 || framesize*count > 5760)
+      if (count <= 0 || framesize*(opus_int32)count > 5760)
          return OPUS_INVALID_PACKET;
       len--;
       /* Padding flag is bit 6 */
-- 
GitLab