From: Leo Izen <leo.izen@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 3/6] avformat/jpegxl_anim_dec: add FF_JPEGXL_CONTAINER_SIGNATURE_LE
Date: Sun, 18 Jun 2023 18:57:58 -0400
Message-ID: <a6ad6580-6c21-8243-1e2e-d3332590f055@gmail.com> (raw)
In-Reply-To: <20230618215021.3044-3-michael@niedermayer.cc>
On 6/18/23 17:50, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 59828/clusterfuzz-testcase-minimized-ffmpeg_dem_JPEGXL_ANIM_fuzzer-5029813220671488
>
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/jpegxl_anim_dec.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/jpegxl_anim_dec.c b/libavformat/jpegxl_anim_dec.c
> index c62b596f76..7e4d39385c 100644
> --- a/libavformat/jpegxl_anim_dec.c
> +++ b/libavformat/jpegxl_anim_dec.c
> @@ -108,7 +108,7 @@ static int jpegxl_collect_codestream_header(const uint8_t *input_buffer, int inp
>
> static int jpegxl_anim_probe(const AVProbeData *p)
> {
> - uint8_t buffer[4096];
> + uint8_t buffer[4096 + AV_INPUT_BUFFER_PADDING_SIZE];
> int copied;
>
> /* this is a raw codestream */
> @@ -123,7 +123,7 @@ static int jpegxl_anim_probe(const AVProbeData *p)
> if (AV_RL64(p->buf) != FF_JPEGXL_CONTAINER_SIGNATURE_LE)
> return 0;
>
> - if (jpegxl_collect_codestream_header(p->buf, p->buf_size, buffer, sizeof(buffer), &copied) <= 0 || copied <= 0)
> + if (jpegxl_collect_codestream_header(p->buf, p->buf_size, buffer, sizeof(buffer) - AV_INPUT_BUFFER_PADDING_SIZE, &copied) <= 0 || copied <= 0)
> return 0;
>
> if (ff_jpegxl_verify_codestream_header(buffer, copied, 0) >= 1)
> @@ -138,7 +138,8 @@ static int jpegxl_anim_read_header(AVFormatContext *s)
> AVIOContext *pb = s->pb;
> AVStream *st;
> int offset = 0;
> - uint8_t head[256];
> + uint8_t head[256 + AV_INPUT_BUFFER_PADDING_SIZE];
> + const int sizeofhead = sizeof(head) - AV_INPUT_BUFFER_PADDING_SIZE;
> int headsize = 0;
> int ctrl;
> AVRational tb;
> @@ -147,7 +148,7 @@ static int jpegxl_anim_read_header(AVFormatContext *s)
> uint64_t sig16 = avio_rl16(pb);
> if (sig16 == FF_JPEGXL_CODESTREAM_SIGNATURE_LE) {
> AV_WL16(head, sig16);
> - headsize = avio_read(s->pb, head + 2, sizeof(head) - 2);
> + headsize = avio_read(s->pb, head + 2, sizeofhead - 2);
> if (headsize < 0)
> return headsize;
> headsize += 2;
> @@ -178,10 +179,10 @@ static int jpegxl_anim_read_header(AVFormatContext *s)
> if (av_buffer_realloc(&ctx->initial, ctx->initial->size + read) < 0)
> return AVERROR(ENOMEM);
> }
> - jpegxl_collect_codestream_header(buf, read, head + headsize, sizeof(head) - headsize, &copied);
> + jpegxl_collect_codestream_header(buf, read, head + headsize, sizeofhead - headsize, &copied);
> memcpy(ctx->initial->data + (ctx->initial->size - read), buf, read);
> headsize += copied;
> - if (headsize >= sizeof(head) || read < sizeof(buf))
> + if (headsize >= sizeofhead || read < sizeof(buf))
> break;
> }
> }
What's with the commit message? Seems unrelated to the change.
- Leo Izen
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-06-18 22:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-18 21:50 [FFmpeg-devel] [PATCH 1/6] avformat/jpegxl_anim_dec: Perform operations in a different order Michael Niedermayer
2023-06-18 21:50 ` [FFmpeg-devel] [PATCH 2/6] avcodec/utils: fix 2 integer overflows in get_audio_frame_duration() Michael Niedermayer
2023-06-22 23:59 ` Michael Niedermayer
2023-06-18 21:50 ` [FFmpeg-devel] [PATCH 3/6] avformat/jpegxl_anim_dec: add FF_JPEGXL_CONTAINER_SIGNATURE_LE Michael Niedermayer
2023-06-18 22:57 ` Leo Izen [this message]
2023-06-19 17:01 ` Michael Niedermayer
2023-06-20 16:50 ` Leo Izen
2023-06-18 21:50 ` [FFmpeg-devel] [PATCH 4/6] avcodec/evc_parse: Check log2_sub_gop_length Michael Niedermayer
2023-06-18 22:27 ` James Almer
2023-06-18 23:01 ` James Almer
2023-06-19 19:03 ` James Almer
2023-06-18 21:50 ` [FFmpeg-devel] [PATCH 5/6] avcodec/vmixdec: Fix several integer anomalies Michael Niedermayer
2023-07-23 18:07 ` Michael Niedermayer
2023-06-18 21:50 ` [FFmpeg-devel] [PATCH 6/6] doc/developer: Require new modules to include tests Michael Niedermayer
2023-06-18 21:55 ` Lynne
2023-06-19 16:08 ` Anton Khirnov
2023-06-19 9:04 ` Jean-Baptiste Kempf
2023-06-19 16:06 ` Anton Khirnov
2023-06-19 16:09 ` Paul B Mahol
2023-06-21 10:04 ` Anton Khirnov
2023-06-23 23:55 ` Michael Niedermayer
2023-06-18 21:56 ` [FFmpeg-devel] [PATCH 1/6] avformat/jpegxl_anim_dec: Perform operations in a different order Leo Izen
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=a6ad6580-6c21-8243-1e2e-d3332590f055@gmail.com \
--to=leo.izen@gmail.com \
--cc=ffmpeg-devel@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