avformat/oggdec: Initialize return value from ogg_read_page() and check it everywhere
Fixes regression since 9ad47762c1
Fixes: out of array access
Fixes: 22172/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5658535590625280
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -412,6 +412,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid, int probing)
|
|||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
av_free(readout_buf);
|
av_free(readout_buf);
|
||||||
avio_seek(bc, start_pos, SEEK_SET);
|
avio_seek(bc, start_pos, SEEK_SET);
|
||||||
|
*sid = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,6 +423,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid, int probing)
|
|||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
av_free(readout_buf);
|
av_free(readout_buf);
|
||||||
avio_seek(bc, start_pos, SEEK_SET);
|
avio_seek(bc, start_pos, SEEK_SET);
|
||||||
|
*sid = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -661,7 +663,7 @@ static int ogg_get_length(AVFormatContext *s)
|
|||||||
ogg->page_pos = -1;
|
ogg->page_pos = -1;
|
||||||
|
|
||||||
while (!ogg_read_page(s, &i, 1)) {
|
while (!ogg_read_page(s, &i, 1)) {
|
||||||
if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
|
if (i >= 0 && ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
|
||||||
ogg->streams[i].codec) {
|
ogg->streams[i].codec) {
|
||||||
s->streams[i]->duration =
|
s->streams[i]->duration =
|
||||||
ogg_gptopts(s, i, ogg->streams[i].granule, NULL);
|
ogg_gptopts(s, i, ogg->streams[i].granule, NULL);
|
||||||
|
Reference in New Issue
Block a user