aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-09-16 23:12:42 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-16 21:19:24 +0200
commite295b5f3d38f66ba65d3df144fadf57a474de711 (patch)
tree140fd75c649e6165f751ec1ea69acb0fba20c38e /libavformat
parent0699b0836d00dd2b6d7e6161babaea9e2c1bd709 (diff)
downloadffmpeg-e295b5f3d38f66ba65d3df144fadf57a474de711.tar.gz
avformat/mpegts: use actually read packet size in mpegts_resync special case
Fixes: infinite loop Fixes: 37986/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTSRAW_fuzzer-5292311517462528 - Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 83b2e4c8f15a00f037040131e26e20de83f0d842) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mpegts.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 3441e238dc..70b71c2a70 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2634,8 +2634,8 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren
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 - back, SEEK_CUR);
+ if (current_packet[0] == 0x80 && current_packet[12] == 0x47 && pos >= TS_PACKET_SIZE) {
+ avio_seek(pb, 12 - TS_PACKET_SIZE, SEEK_CUR);
return 0;
}