From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id AC4CF470C1
	for <ffmpegdev@gitmailbox.com>; Wed, 26 Jul 2023 23:27:14 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2841068C9AA;
	Thu, 27 Jul 2023 02:27:11 +0300 (EEST)
Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net
 [217.70.183.193])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 661D368C806
 for <ffmpeg-devel@ffmpeg.org>; Thu, 27 Jul 2023 02:27:04 +0300 (EEST)
Received: by mail.gandi.net (Postfix) with ESMTPSA id 6990F240003
 for <ffmpeg-devel@ffmpeg.org>; Wed, 26 Jul 2023 23:27:03 +0000 (UTC)
Date: Thu, 27 Jul 2023 01:27:02 +0200
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20230726232702.GX7802@pb2>
References: <20230413094441.56225-1-lq@chinaffmpeg.org>
 <20230413094441.56225-3-lq@chinaffmpeg.org>
MIME-Version: 1.0
In-Reply-To: <20230413094441.56225-3-lq@chinaffmpeg.org>
X-GND-Sasl: michael@niedermayer.cc
Subject: Re: [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux
 hevc in enhanced flv
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: multipart/mixed; boundary="===============3015882168755726290=="
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20230726232702.GX7802@pb2/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--===============3015882168755726290==
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="ixLxI13kJ3fj8Y4v"
Content-Disposition: inline


--ixLxI13kJ3fj8Y4v
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Apr 13, 2023 at 05:44:37PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/flvdec.c | 58 ++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 50 insertions(+), 8 deletions(-)
>=20
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index d83edff727..6a1e6e7ff0 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -79,6 +79,8 @@ typedef struct FLVContext {
>      int64_t last_ts;
>      int64_t time_offset;
>      int64_t time_pos;
> +
> +    uint8_t exheader;
>  } FLVContext;
> =20
>  /* AMF date type */
> @@ -302,13 +304,25 @@ static void flv_set_audio_codec(AVFormatContext *s,=
 AVStream *astream,
>      }
>  }
> =20
> -static int flv_same_video_codec(AVCodecParameters *vpar, int flags)
> +static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *v=
par, int flags)
>  {
>      int flv_codecid =3D flags & FLV_VIDEO_CODECID_MASK;
> +    FLVContext *flv =3D s->priv_data;
> =20
>      if (!vpar->codec_id && !vpar->codec_tag)
>          return 1;
> =20
> +    if (flv->exheader) {
> +        uint8_t *codec_id_str =3D (uint8_t *)s->pb->buf_ptr;
> +        uint32_t codec_id =3D codec_id_str[3] | codec_id_str[2] << 8 | c=
odec_id_str[1] << 16 | codec_id_str[0] << 24;

pb->buf_ptr is in general not supposed to be directly accessed

In this case here it segfaults

READ of size 1 at 0x6100000003b7 thread T0
    #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29
    #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177
    #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15
    #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15
    #4 0x71d158 in avformat_find_stream_info ffmpeg/libavformat/demux.c:263=
4:15
    #5 0x4c821b in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:=
206:11

can you remove pb->buf_ptr use ?
I can fix it too but i have no testcase and fate doesnt cover this so my fi=
x would
be untested ...

thx

[...]
--=20
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator

--ixLxI13kJ3fj8Y4v
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZMGrwgAKCRBhHseHBAsP
q8wHAJ4n5AsAYUxGuI6CojexXpzkCDwfOwCbBS3+JZEodOJX1Sln2+vNwTZdpGE=
=HwIq
-----END PGP SIGNATURE-----

--ixLxI13kJ3fj8Y4v--

--===============3015882168755726290==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
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".

--===============3015882168755726290==--