From: michaelni via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: michaelni <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avformat/img2dec: Check avio_size() for failure (PR #21384)
Date: Mon, 05 Jan 2026 17:12:22 -0000
Message-ID: <176763314293.25.8417260284875775060@4457048688e7> (raw)
PR #21384 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21384
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21384.patch
More complete fix for #YWH-PGM40646-32
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>From 1c214abfd52ac09cb5cb71de70e6475bb7f80747 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
Date: Mon, 5 Jan 2026 18:07:49 +0100
Subject: [PATCH] avformat/img2dec: Check avio_size() for failure
More complete fix for #YWH-PGM40646-32
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/img2dec.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 586634c0c3..523015e4c6 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -367,7 +367,6 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
int i, res;
int ret[3] = { 0 };
int64_t size[3] = { 0 };
- int64_t total_size;
AVIOContext *f[3] = { NULL };
AVCodecParameters *par = s1->streams[0]->codecpar;
@@ -458,15 +457,15 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
}
}
- total_size = size[0];
- if (total_size > INT64_MAX - size[1])
- return AVERROR_INVALIDDATA;
- total_size += size[1];
- if (total_size > INT64_MAX - size[2])
- return AVERROR_INVALIDDATA;
- total_size += size[2];
- if (total_size > INT_MAX)
- return AVERROR_INVALIDDATA;
+ int64_t total_size = 0;
+ for(int i = 0; i < 3; i++) {
+ if (size[i] < 0)
+ return size[i];
+ if (total_size > INT64_MAX - size[i])
+ return AVERROR_INVALIDDATA;
+
+ total_size += size[i];
+ }
res = av_new_packet(pkt, total_size);
if (res < 0) {
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
next reply other threads:[~2026-01-05 17:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 17:12 michaelni via ffmpeg-devel [this message]
2026-01-05 22:38 ` [FFmpeg-devel] " Kieran Kunhya via ffmpeg-devel
2026-01-08 2:52 ` Michael Niedermayer via ffmpeg-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176763314293.25.8417260284875775060@4457048688e7 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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