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>
This commit is contained in:
parent
36786f54e7
commit
b0b8ce0002
@ -2765,15 +2765,16 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren
|
|||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
int c, i;
|
int c, i;
|
||||||
uint64_t pos = avio_tell(pb);
|
uint64_t pos = avio_tell(pb);
|
||||||
|
int64_t back = FFMIN(seekback, pos);
|
||||||
avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR);
|
|
||||||
|
|
||||||
//Special case for files like 01c56b0dc1.ts
|
//Special case for files like 01c56b0dc1.ts
|
||||||
if (current_packet[0] == 0x80 && current_packet[12] == 0x47) {
|
if (current_packet[0] == 0x80 && current_packet[12] == 0x47) {
|
||||||
avio_seek(pb, 12, SEEK_CUR);
|
avio_seek(pb, 12 - back, SEEK_CUR);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avio_seek(pb, -back, SEEK_CUR);
|
||||||
|
|
||||||
for (i = 0; i < ts->resync_size; i++) {
|
for (i = 0; i < ts->resync_size; i++) {
|
||||||
c = avio_r8(pb);
|
c = avio_r8(pb);
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user