From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C3CD74A620 for ; Mon, 1 Apr 2024 23:57:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C30F268CFEC; Tue, 2 Apr 2024 02:57:22 +0300 (EEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9BB2068C3B1 for ; Tue, 2 Apr 2024 02:57:16 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DFBE320003 for ; Mon, 1 Apr 2024 23:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1712015836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=88sM01aTCyeAQzDbZi/ohK94mzjfmlq80R/VRZJ1NgQ=; b=R13arXXdM4/wIkS461LCd0hC91nZxXbCJY7hU9vWxCtR2/NZEGBSHshzoG4osatsv89rH3 yBtyCedGGE7MLtl8kHBD1tkA1YMV81v5jLJwj/e6Qrg04ch5HGcB25r3JG5NW53yAOjJNW vhgLZp1yUsqp/UrAF3G+x86eHa93MqB5td3pEHGbFXYR6ljbm7k/dg73L6QVamt5K7DRhx 26TNrGcK6fHYdSVG4iGNUra637KHGUTiiWsNb4J1y//nUIxgC2hHfzs4LBqDahuGOxyWEv cp6JBZ/fZ+f7ZA8/Ludok2oDsi02C6TELqLBzmbrCfsojxQseW+zjhuWu4H3iQ== Date: Tue, 2 Apr 2024 01:57:15 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240401235715.GO6420@pb2> References: <20240401205607.9093-1-michael@niedermayer.cc> <20240401205607.9093-4-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 4/6] avformat/demux_utils: Avoid leaking the packet in ff_add_attached_pic() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============4864955481804416354==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4864955481804416354== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="F6H2U61PSmijDX/I" Content-Disposition: inline --F6H2U61PSmijDX/I Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 01, 2024 at 11:35:56PM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: memleak > > Fixes: 67714/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-56715= 70999476224 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/demux_utils.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/libavformat/demux_utils.c b/libavformat/demux_utils.c > > index 86f551245be..96e6e20d1ec 100644 > > --- a/libavformat/demux_utils.c > > +++ b/libavformat/demux_utils.c > > @@ -123,9 +123,9 @@ int ff_add_attached_pic(AVFormatContext *s, AVStrea= m *st0, AVIOContext *pb, > > if (!st && !(st =3D avformat_new_stream(s, NULL))) > > return AVERROR(ENOMEM); > > pkt =3D &st->attached_pic; > > + av_packet_unref(pkt); > > if (buf) { > > av_assert1(*buf); > > - av_packet_unref(pkt); > > pkt->buf =3D *buf; > > pkt->data =3D (*buf)->data; > > pkt->size =3D (*buf)->size - AV_INPUT_BUFFER_PADDING_SIZE; >=20 > This seems to be from the ff_add_attached_pic() call in > mov_read_chapters() with the referenced stream having been created in > mov_read_covr(). The latter does not set a proper id -- it just takes > what avformat_new_stream() sets as id on every new stream (namely zero). > So it makes no real sense to compare it to the ids contained in > chapter_tracks (can really every track be reinterpreted as chapter > track?). But I am no mov/mp4 expert. > Anyway, does the following fix it? >=20 > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 7bdeeb99f9..51d97296f1 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -8820,7 +8820,7 @@ static void mov_read_chapters(AVFormatContext *s) >=20 > if (st->codecpar->codec_type =3D=3D AVMEDIA_TYPE_VIDEO) { > st->disposition |=3D AV_DISPOSITION_ATTACHED_PIC | > AV_DISPOSITION_TIMED_THUMBNAILS; > - if (sti->nb_index_entries) { > + if (!st->attached_pic.data && sti->nb_index_entries) { > // Retrieve the first frame, if possible > AVIndexEntry *sample =3D &sti->index_entries[0]; > if (avio_seek(sc->pb, sample->pos, SEEK_SET) !=3D > sample->pos) { > s Yes, this fixes it too, please apply and backport as needed thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Homeopathy is like voting while filling the ballot out with transparent ink. Sometimes the outcome one wanted occurs. Rarely its worse than filling out a ballot properly. --F6H2U61PSmijDX/I Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZgtJ2wAKCRBhHseHBAsP q35vAJ9yPz978y2qgFPRaJSQelyVeXXg6QCgg0JqIeIufx4jd03qdPYx61P+TsU= =5M8b -----END PGP SIGNATURE----- --F6H2U61PSmijDX/I-- --===============4864955481804416354== 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". --===============4864955481804416354==--