mirror of https://git.ffmpeg.org/ffmpeg.git
libavformat/utils: consider avio_size() failure in ffio_limit()
Fixes: Timeout (>20sec -> 3ms)
Fixes: 26918/clusterfuzz-testcase-minimized-ffmpeg_dem_THP_fuzzer-5750425191710720
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1b1dac2716
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
49cb678028
commit
10a0989e03
|
@ -243,13 +243,16 @@ int av_format_get_probe_score(const AVFormatContext *s)
|
||||||
int ffio_limit(AVIOContext *s, int size)
|
int ffio_limit(AVIOContext *s, int size)
|
||||||
{
|
{
|
||||||
if (s->maxsize>= 0) {
|
if (s->maxsize>= 0) {
|
||||||
int64_t remaining= s->maxsize - avio_tell(s);
|
int64_t pos = avio_tell(s);
|
||||||
|
int64_t remaining= s->maxsize - pos;
|
||||||
if (remaining < size) {
|
if (remaining < size) {
|
||||||
int64_t newsize = avio_size(s);
|
int64_t newsize = avio_size(s);
|
||||||
if (!s->maxsize || s->maxsize<newsize)
|
if (!s->maxsize || s->maxsize<newsize)
|
||||||
s->maxsize = newsize - !newsize;
|
s->maxsize = newsize - !newsize;
|
||||||
remaining= s->maxsize - avio_tell(s);
|
if (pos > s->maxsize && s->maxsize >= 0)
|
||||||
remaining= FFMAX(remaining, 0);
|
s->maxsize = AVERROR(EIO);
|
||||||
|
if (s->maxsize >= 0)
|
||||||
|
remaining = s->maxsize - pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->maxsize>= 0 && remaining+1 < size) {
|
if (s->maxsize>= 0 && remaining+1 < size) {
|
||||||
|
|
Loading…
Reference in New Issue