diff mbox series

[FFmpeg-devel,2/5] avformat/apngenc: Check for incomplete chunks

Message ID DB6PR0101MB22145D26553CCB850AE5264F8FBE9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 3204572a1a5dc19e11356cdf39378a171189149b
Headers show
Series [FFmpeg-devel,1/5] avcodec/apng: Add APNG_FCTL_CHUNK_SIZE define | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 4, 2022, 3:25 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apngenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index 88d4a41462..7443c77504 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -50,7 +50,7 @@  typedef struct APNGMuxContext {
 static uint8_t *apng_find_chunk(uint32_t tag, uint8_t *buf, size_t length)
 {
     size_t b;
-    for (b = 0; b < length; b += AV_RB32(buf + b) + 12)
+    for (b = 0; AV_RB32(buf + b) + 12ULL <= length - b; b += AV_RB32(buf + b) + 12ULL)
         if (AV_RB32(&buf[b + 4]) == tag)
             return &buf[b];
     return NULL;