Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 5/5] avformat/iamf: Check substreams in ff_iamf_free_audio_element()
Date: Mon, 15 Jul 2024 12:16:08 -0300
Message-ID: <a8657646-4534-4978-9f49-efa3dc276b90@gmail.com> (raw)
In-Reply-To: <20240623230137.1749178-5-michael@niedermayer.cc>

On 6/23/2024 8:01 PM, Michael Niedermayer wrote:
> Fixes: member access within null pointer of type 'IAMFSubStream' (aka 'struct IAMFSubStream')
> Fixes: 69795/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6216287009701888
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavformat/iamf.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/iamf.c b/libavformat/iamf.c
> index 5de70dc0828..364cb60e021 100644
> --- a/libavformat/iamf.c
> +++ b/libavformat/iamf.c
> @@ -74,8 +74,10 @@ void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)
>       if (!audio_element)
>           return;
>   
> -    for (int i = 0; i < audio_element->nb_substreams; i++)
> -        avcodec_parameters_free(&audio_element->substreams[i].codecpar);
> +    if (audio_element->nb_substreams)
> +        for (int i = 0; i < audio_element->nb_substreams; i++) {
> +            avcodec_parameters_free(&audio_element->substreams[i].codecpar);
> +        }
>       av_free(audio_element->substreams);
>       av_free(audio_element->layers);
>       av_iamf_audio_element_free(&audio_element->element);

Sorry, i missed this.

nb_substreams shouldn't be anything but 0 here if nb_substreams is NULL, 
so the following is IMO better:

> diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
> index 9cec12d46f..a69d4a2f3a 100644
> --- a/libavformat/iamf_parse.c
> +++ b/libavformat/iamf_parse.c
> @@ -594,7 +594,7 @@ static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
>      FFIOContext b;
>      AVIOContext *pbc;
>      uint8_t *buf;
> -    unsigned audio_element_id, codec_config_id, num_parameters;
> +    unsigned audio_element_id, nb_substreams, codec_config_id, num_parameters;
>      int audio_element_type, ret;
> 
>      buf = av_malloc(len);
> @@ -649,14 +649,15 @@ static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
>          goto fail;
>      }
> 
> -    audio_element->nb_substreams = ffio_read_leb(pbc);
> +    nb_substreams = ffio_read_leb(pbc);
>      audio_element->codec_config_id = codec_config_id;
>      audio_element->audio_element_id = audio_element_id;
> -    audio_element->substreams = av_calloc(audio_element->nb_substreams, sizeof(*audio_element->substreams));
> +    audio_element->substreams = av_calloc(nb_substreams, sizeof(*audio_element->substreams));
>      if (!audio_element->substreams) {
>          ret = AVERROR(ENOMEM);
>          goto fail;
>      }
> +    audio_element->nb_substreams = nb_substreams;
> 
>      element = audio_element->element = av_iamf_audio_element_alloc();
>      if (!element) {
_______________________________________________
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".

  parent reply	other threads:[~2024-07-15 15:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-23 23:01 [FFmpeg-devel] [PATCH 1/5] avcodec/aac/aacdec_usac: Test ac in usac Michael Niedermayer
2024-06-23 23:01 ` [FFmpeg-devel] [PATCH 2/5] avcodec/hevc/hevcdec: Do not allow changes to parameter sets between slices Michael Niedermayer
2024-06-25  8:59   ` Anton Khirnov
2024-06-25 23:27     ` Michael Niedermayer
2024-06-26  6:36       ` Anton Khirnov
2024-06-23 23:01 ` [FFmpeg-devel] [PATCH 3/5] avcodec/hevc/hevcdec: SPS not set (or cleared) after frame start Michael Niedermayer
2024-06-25  9:00   ` Anton Khirnov
2024-06-25 23:52     ` Michael Niedermayer
2024-06-26  6:38       ` Anton Khirnov
2024-06-26 23:05         ` Michael Niedermayer
2024-06-23 23:01 ` [FFmpeg-devel] [PATCH 4/5] avcodec/hevc/hevcdec: Do not allow slices to depend on failed slices Michael Niedermayer
2024-06-25  9:04   ` Anton Khirnov
2024-06-23 23:01 ` [FFmpeg-devel] [PATCH 5/5] avformat/iamf: Check substreams in ff_iamf_free_audio_element() Michael Niedermayer
2024-07-15 14:25   ` Michael Niedermayer
2024-07-15 15:16   ` James Almer [this message]
2024-06-25 23:35 ` [FFmpeg-devel] [PATCH 1/5] avcodec/aac/aacdec_usac: Test ac in usac Lynne via ffmpeg-devel
2024-06-25 23:57   ` Michael Niedermayer
2024-06-26  6:58     ` Lynne via ffmpeg-devel
2024-06-26 18:57       ` Michael Niedermayer
2024-06-26 19:45       ` Andreas Rheinhardt
2024-06-26 22:46         ` Lynne 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=a8657646-4534-4978-9f49-efa3dc276b90@gmail.com \
    --to=jamrial@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