From d517a84c85ae695085f3d0ea25156b68fafe7356 Mon Sep 17 00:00:00 2001 From: James Almer <jamrial@gmail.com> Date: Fri, 28 Jun 2024 21:06:53 -0300 Subject: [PATCH] avformat/mov: check that sample and chunk count is 1 for HEIF Fixes NULL pointer dereference in broken/fuzzed streams. Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit 2aa63784b533f461785c3e767e354e84c7e2c8c2) --- libavformat/mov.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 83a48335ac..a6732ad3e0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -9574,6 +9574,9 @@ static int mov_read_header(AVFormatContext *s) st->codecpar->width = item->width; st->codecpar->height = item->height; + if (sc->sample_count != 1 || sc->chunk_count != 1) + return AVERROR_INVALIDDATA; + sc->sample_sizes[0] = item->extent_length; sc->chunk_offsets[0] = item->extent_offset + offset;