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 6435340DB1 for ; Sun, 10 Apr 2022 14:46:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E20868B34D; Sun, 10 Apr 2022 17:46:33 +0300 (EEST) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4265568B32C for ; Sun, 10 Apr 2022 17:46:27 +0300 (EEST) Received: by mail-ot1-f43.google.com with SMTP id i23-20020a9d6117000000b005cb58c354e6so9589851otj.10 for ; Sun, 10 Apr 2022 07:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:content-language:to :references:from:subject:in-reply-to:content-transfer-encoding; bh=KKCf5ihBkdu6Xys2xSQRj9UdGBzLmZtoi1HNeBaOkG0=; b=ATujCZO3SyTajpfnsQtRtqk+T+QjHDt8R7l0h/PpP+M6fIYuGOFcoWxSbCFQ6UM+nE kHKj5LRmcw48hVVxLftIk2Td+p+dGabCxpam2RRvZJWZk/QPy1AuOFFfloxpuWjX+/hG iFSLkFKgaOhHDSvdS8grdpqzPrzS/lNd6DVyk+qk1TBwR8L3HdcjjTcWBGmYMKm5EWms Tcoy4uz76w5Y8GdMsBamtM1DpaN13R8uu0M11nA/chIYyl0HIY+gVJagyaVzl6rIGqMi uKCg1IZwpU5OyzdqmevtYbVtYYIUE9p7On+lX3nXpysMmEcuFVcrToTEJJLmxthLghPc jNEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:references:from:subject:in-reply-to :content-transfer-encoding; bh=KKCf5ihBkdu6Xys2xSQRj9UdGBzLmZtoi1HNeBaOkG0=; b=Tr9GtXJz3MIU5D4kEiWe8qbahvCDkMs1jinIcuafJ37h8kH7nG/vjw1ToXSo2cPsuJ 0gn6nec7Ig5Cs9tfSLrPFpIQWA9/OyMmMMDWZNTcD0lHXUiZVMEX7yrVuKOsquO8DZBK J4Y9I5HTGpGr5i8Dbx9n3pbW0Ok331CTarCn8UnR5Q9W6TX01gvaZVDCkI0cEKnBPBDC deUE3V4mO50ZBkXhVCUDlgh6eOItFHdzOH9GB0tfB5v28OOyLSM/N0aXeEe59yZdBYQ+ 5iaJKfny+Qb58Sgo9jXMYwk8Zvb4b1LjIpWeKHXJ/angkjhwNfifHpeG0MmjDYjpGJiy r6Vw== X-Gm-Message-State: AOAM532RPZzDJoFto9wrxaNMnLYcC8pzS0Fv1TEK/6eTmRAsbJXYMZPi bOuiXWzDBotC8440KDTs667ugGVMF2Y= X-Google-Smtp-Source: ABdhPJxutc7ZWOpuaHChww05+kteVUmhvGiTNnisYYiCFfTUEj3PxOf32OGAlKPK7w0H/3KJj4dbkg== X-Received: by 2002:a05:6830:16c3:b0:5b2:3700:654a with SMTP id l3-20020a05683016c300b005b23700654amr9676712otr.353.1649601985358; Sun, 10 Apr 2022 07:46:25 -0700 (PDT) Received: from [192.168.0.12] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id c12-20020a9d75cc000000b005b24b061940sm11212590otl.33.2022.04.10.07.46.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Apr 2022 07:46:24 -0700 (PDT) Message-ID: <8b56d0cd-9f30-b4ab-7b18-4b2d6cfc5e11@gmail.com> Date: Sun, 10 Apr 2022 11:46:24 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220329212459.23440-1-michael@niedermayer.cc> <62c40964-d827-d044-cec3-233bfc04aaf1@gmail.com> <20220330105802.GO2829255@pb2> <20220410141413.GC2829255@pb2> From: James Almer In-Reply-To: <20220410141413.GC2829255@pb2> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/pcm_rechunk_bsf: unref packet before putting a new one in 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 4/10/2022 11:14 AM, Michael Niedermayer wrote: > On Sat, Apr 09, 2022 at 08:56:05PM +0200, Marton Balint wrote: >> >> >> On Wed, 30 Mar 2022, Michael Niedermayer wrote: >> >>> On Tue, Mar 29, 2022 at 06:33:06PM -0300, James Almer wrote: >>>> On 3/29/2022 6:24 PM, Michael Niedermayer wrote: >>>>> Fixes: memleak >>>>> Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_fuzzer-5562089618407424 >>>>> >>>>> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg >>>>> Signed-off-by: Michael Niedermayer >>>>> --- >>>>> libavcodec/pcm_rechunk_bsf.c | 1 + >>>>> 1 file changed, 1 insertion(+) >>>>> >>>>> diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c >>>>> index 108d9e90b9..3f43934fe9 100644 >>>>> --- a/libavcodec/pcm_rechunk_bsf.c >>>>> +++ b/libavcodec/pcm_rechunk_bsf.c >>>>> @@ -153,6 +153,7 @@ static int rechunk_filter(AVBSFContext *ctx, AVPacket *pkt) >>>>> } >>>>> } >>>>> + av_packet_unref(s->in_pkt); >>>> >>>> This looks to me like it revealed a bug in the code above, which is meant to >>>> ensure s->in_pkt will be blank at this point. It should be fixed there >>>> instead. >>> >>> IIRC the problem was a input packet with size 0 >>> the code seems to assume 0 meaning no packet >> >> Is that valid here? The docs says that the encoders can generate 0 sized >> packets if there is side data in them. However - the PCM rechunk BSF using >> PCM packets - I am not sure this is intentional here. > > where exactly is this written ? > > >> >> So overall it looks to me that the PCM rechunk BSF should reject 0 sized >> packets with AVERROR_INVALIDDATA, and the encoder or demuxer which produces >> the 0 sized packets should be fixed. > > There is no encoder or demuxer. There is just the fuzzer which excercies > the whole space of allowed parameters of the BSFs > and either such zero packets are valid or they are not. > if not, then a check could be added to av_bsf_send_packet() that feels a > bit broad though. > > i can add a check to pcm_rechunk_bsf but it feels a bit odd if these are > valid and just not supposed to come out of the encoders > > do you see some problem with these packets ? > that makes it better to just reject them ? > > (error you enountered a packet which makes no difference seems a bit odd > in its own too. That probably should only be a warning) > > thx > > diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c > index 42cc1b5ab0..ae16112285 100644 > --- a/libavcodec/bsf.c > +++ b/libavcodec/bsf.c > @@ -212,6 +212,11 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) > return 0; > } > > + if (pkt->size == 0 && pkt->side_data_elems == 0) { > + av_log(ctx, AV_LOG_ERROR, "Zero packet is not allowed.\n"); > + return AVERROR(EINVAL); > + } To make this behave like avcodec_send_packet(), it should instead be diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 42cc1b5ab0..01ed9db258 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -205,6 +205,9 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) FFBSFContext *const bsfi = ffbsfcontext(ctx); int ret; + if (pkt && !pkt->size && pkt->data) + return AVERROR(EINVAL); + if (!pkt || IS_EMPTY(pkt)) { if (pkt) av_packet_unref(pkt); _______________________________________________ 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".