ref: 26451fef9a2b46e65241d839ea3b59e8697128a3
parent: e9b53212f2ad1ee7dbf44d941c15013e23cec932
author: Jean-Marc Valin <[email protected]>
date: Thu Oct 13 16:12:05 EDT 2011
Improved test for fishy redundancy length
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -334,7 +334,9 @@
/* redundancy_bytes will be at least two, in the non-hybrid case due to the ec_tell() check above */
redundancy_bytes = mode==MODE_HYBRID ? (opus_int32)ec_dec_uint(&dec, 256)+2 : len-((ec_tell(&dec)+7)>>3);
len -= redundancy_bytes;
- if (len<0)
+ /* This is a sanity check. It should never happen for a valid packet,
+ so the exact behaviour is not normative. */
+ if (len*8 < ec_tell(&dec))
{
len=0;
redundancy_bytes=0;