Commit 67273ef3 authored by James Zern's avatar James Zern Committed by Timothy B. Terriberry

op_fetch_and_process_page: Fix int64 overflow

Check for overflow with a negative diff.
Signed-off-by: Timothy B. Terriberry's avatarTimothy B. Terriberry <tterribe@xiph.org>
parent 567165a7
...@@ -2078,7 +2078,11 @@ static int op_fetch_and_process_page(OggOpusFile *_of, ...@@ -2078,7 +2078,11 @@ static int op_fetch_and_process_page(OggOpusFile *_of,
&&OP_LIKELY(diff<total_duration)){ &&OP_LIKELY(diff<total_duration)){
cur_packet_gp=prev_packet_gp; cur_packet_gp=prev_packet_gp;
for(pi=0;pi<op_count;pi++){ 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=durations[pi]+1;
}
else diff=durations[pi]-diff;
/*If we have samples to trim...*/ /*If we have samples to trim...*/
if(diff>0){ if(diff>0){
/*If we trimmed the entire packet, stop (the spec says encoders /*If we trimmed the entire packet, stop (the spec says encoders
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment