Commit d6697905 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry
Browse files

Fix a granpos calculation we assumed couldn't fail.

It was only guaranteed to work in the seekable case.
Thanks to Radio Stadtfilter 96.3Mhz for sending a stream which
 triggered this failure.
parent 2ab13b78
...@@ -2519,9 +2519,17 @@ static ogg_int64_t op_get_pcm_offset(const OggOpusFile *_of, ...@@ -2519,9 +2519,17 @@ static ogg_int64_t op_get_pcm_offset(const OggOpusFile *_of,
_gp=links[_li].pcm_end; _gp=links[_li].pcm_end;
} }
if(OP_LIKELY(op_granpos_cmp(_gp,links[_li].pcm_start)>0)){ if(OP_LIKELY(op_granpos_cmp(_gp,links[_li].pcm_start)>0)){
OP_ALWAYS_TRUE(!op_granpos_diff(&delta,_gp,links[_li].pcm_start)); if(OP_UNLIKELY(op_granpos_diff(&delta,_gp,links[_li].pcm_start)<0)){
/*This means an unseekable stream claimed to have a page from more than
2 billion days after we joined.*/
return OP_INT64_MAX;
if(delta<links[_li].head.pre_skip)delta=0; if(delta<links[_li].head.pre_skip)delta=0;
else delta-=links[_li].head.pre_skip; else delta-=links[_li].head.pre_skip;
/*In the seekable case, _gp was limited by pcm_end.
In the unseekable case, pcm_offset should be 0.*/
pcm_offset+=delta; pcm_offset+=delta;
} }
return pcm_offset; return pcm_offset;
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