[opus] [PATCH 2/2] op_fetch_and_process_page: fix int64 overflow
James Zern
jzern at google.com
Mon Nov 20 21:07:21 UTC 2017
check for overflow with a negative diff
---
src/opusfile.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/opusfile.c b/src/opusfile.c
index df326af..2bef277 100644
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -2078,7 +2078,10 @@ static int op_fetch_and_process_page(OggOpusFile *_of,
&&OP_LIKELY(diff<total_duration)){
cur_packet_gp=prev_packet_gp;
for(pi=0;pi<op_count;pi++){
- diff=durations[pi]-diff;
+ /*Check for overflow.*/
+ if(diff<0&&OP_UNLIKELY(OP_INT64_MAX+diff<durations[pi])){
+ diff=0;
+ } else diff=durations[pi]-diff;
/*If we have samples to trim...*/
if(diff>0){
/*If we trimmed the entire packet, stop (the spec says encoders
--
2.15.0.448.gf294e3d99a-goog
More information about the opus
mailing list