* [FFmpeg-devel] [PR] avformat/mov: add overflow checks to item offset values (PR #21479)
@ 2026-01-15 20:15 James Almer via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: James Almer via ffmpeg-devel @ 2026-01-15 20:15 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: James Almer
PR #21479 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21479
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21479.patch
Fixes issue #21478.
>From d2b178764600839d76a4437e3d7bbc808b38ed10 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Thu, 15 Jan 2026 17:14:29 -0300
Subject: [PATCH] avformat/mov: add overflow checks to item offset values
Fixes issue #21478.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavformat/mov.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 009ddfec80..f219dd2625 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -10252,6 +10252,9 @@ static int read_image_grid(AVFormatContext *s, const HEIFGrid *grid,
offset = c->idat_offset;
}
+ if (offset > INT64_MAX - item->extent_offset)
+ return AVERROR_INVALIDDATA;
+
avio_seek(s->pb, item->extent_offset + offset, SEEK_SET);
avio_r8(s->pb); /* version */
@@ -10335,6 +10338,9 @@ static int read_image_iovl(AVFormatContext *s, const HEIFGrid *grid,
offset = c->idat_offset;
}
+ if (offset > INT64_MAX - item->extent_offset)
+ return AVERROR_INVALIDDATA;
+
avio_seek(s->pb, item->extent_offset + offset, SEEK_SET);
avio_r8(s->pb); /* version */
@@ -10408,6 +10414,9 @@ static int mov_parse_exif_item(AVFormatContext *s,
if (!buf)
return AVERROR(ENOMEM);
+ if (offset > INT64_MAX - ref->extent_offset)
+ return AVERROR_INVALIDDATA;
+
avio_seek(s->pb, ref->extent_offset + offset, SEEK_SET);
err = avio_read(s->pb, buf->data, ref->extent_length);
if (err != ref->extent_length) {
@@ -10621,6 +10630,9 @@ static int mov_parse_heif_items(AVFormatContext *s)
if (err)
return AVERROR_INVALIDDATA;
+ if (offset > INT64_MAX - item->extent_offset)
+ return AVERROR_INVALIDDATA;
+
sc->chunk_offsets[0] = item->extent_offset + offset;
if (item->item_id == mov->primary_item_id)
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-15 20:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-15 20:15 [FFmpeg-devel] [PR] avformat/mov: add overflow checks to item offset values (PR #21479) James Almer via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git