diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-05-07 12:38:26 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-07-03 12:10:24 +0200 |
commit | 71fefa15c061cebceddaa2e2c0b2df999770c1a2 (patch) | |
tree | 2118d255bb299256cd71fd12c6599668ecc80e45 | |
parent | ddaee77e3c4d07e2f1a242ddc6ea17760b4be9fa (diff) | |
download | ffmpeg-71fefa15c061cebceddaa2e2c0b2df999770c1a2.tar.gz |
avformat/mpegts: Shuffle avio_seek
This avoids accessing an old, no longer valid buffer.
Fixes: out of array access
Fixes: crash_audio-2020
Found-by: le wu <shoulewoba@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cd74af14162c803f18e90bb12b52135e893d990c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/mpegts.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 3fc374cbf4..fe502ae77e 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2631,15 +2631,16 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren AVIOContext *pb = s->pb; int c, i; uint64_t pos = avio_tell(pb); - - avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR); + int64_t back = FFMIN(seekback, pos); //Special case for files like 01c56b0dc1.ts if (current_packet[0] == 0x80 && current_packet[12] == 0x47) { - avio_seek(pb, 12, SEEK_CUR); + avio_seek(pb, 12 - back, SEEK_CUR); return 0; } + avio_seek(pb, -back, SEEK_CUR); + for (i = 0; i < ts->resync_size; i++) { c = avio_r8(pb); if (avio_feof(pb)) |