diff mbox series

[FFmpeg-devel,2/5] avformat/mpeg: Check len in mpegps_probe()

Message ID 20240607003215.1723906-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avformat/mov: Check requested_sample before using it | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer June 7, 2024, 12:32 a.m. UTC
Fixes: CID1473590 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mpeg.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 5556861e1c4..c3dff3e4ea2 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -76,6 +76,9 @@  static int mpegps_probe(const AVProbeData *p)
             int pes  = endpes <= i && check_pes(p->buf + i, p->buf + p->buf_size);
             int pack = check_pack_header(p->buf + i);
 
+            if (len > INT_MAX - i)
+                break;
+
             if (code == SYSTEM_HEADER_START_CODE)
                 sys++;
             else if (code == PACK_START_CODE && pack)