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 E453046A33 for ; Wed, 2 Aug 2023 11:19:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 50D0F68BD6A; Wed, 2 Aug 2023 14:19:42 +0300 (EEST) Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51ED068A39C for ; Wed, 2 Aug 2023 14:19:35 +0300 (EEST) Received: from mail.ispras.ru (unknown [83.149.199.84]) by mail.ispras.ru (Postfix) with ESMTPSA id 795B940F1DE0; Wed, 2 Aug 2023 11:19:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 795B940F1DE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1690975174; bh=2MdmkUl/RhxEgd2wK9yjN2aBj/1ByWJHsg7h/R63PVQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BPzzjPkmg4ugIkXnnvreeebDa7JnWuJL6nzPxY1JAt16IZ3KBykBdS+klLyPDSjna KkVNL7+4kFnoOQ/NIF+gYGa9SoxDKIvyfX9Wo3um9VuQZeZX+FbqaYSEaHljo5r9Vk RaYCNXnVAkscyXfhoVXiFDHirhH+pBMxkHtR5Ln4= MIME-Version: 1.0 Date: Wed, 02 Aug 2023 14:19:34 +0300 From: kobrineli@ispras.ru To: FFmpeg development discussions and patches In-Reply-To: References: <20230802093524.1136658-1-kobrineli@ispras.ru> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: kobrineli@ispras.ru X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] libswresample: Prevent out of bounds. 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 Cc: Andreas Rheinhardt 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: I've found out that `in_fmt` is equal to -1 at the place of error, so we just need to insert check at the beginning of `swr_init` function to check fmts positivity. On 2023-08-02 13:51, Andreas Rheinhardt wrote: > kobrineli: > >> From: Eli Kobrin >> >> We've been fuzzing torchvision with >> [sydr-fuzz](https://github.com/ispras/oss-sydr-fuzz) >> and found out of bounds error in ffmpeg project at audioconvert.c:51. >> To prevent error we need to insert corresponding check. >> >> Signed-off-by: Eli Kobrin >> --- >> libswresample/audioconvert.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/libswresample/audioconvert.c >> b/libswresample/audioconvert.c >> index 1d75ba1495..701f4808a0 100644 >> --- a/libswresample/audioconvert.c >> +++ b/libswresample/audioconvert.c >> @@ -148,7 +148,12 @@ AudioConvert *swri_audio_convert_alloc(enum >> AVSampleFormat out_fmt, >> int flags) >> { >> AudioConvert *ctx; >> - conv_func_type *f = >> fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt) + >> AV_SAMPLE_FMT_NB*av_get_packed_sample_fmt(in_fmt)]; >> + >> + size_t idx = av_get_packed_sample_fmt(out_fmt) + AV_SAMPLE_FMT_NB >> * av_get_packed_sample_fmt(in_fmt); >> + if (idx >= AV_SAMPLE_FMT_NB * AV_SAMPLE_FMT_NB) >> + return NULL; >> + >> + conv_func_type *f = fmt_pair_to_conv_functions[idx]; >> >> if (!f) >> return NULL; > > Something seems to be using an invalid sample format (either out_fmt or > in_fmt). You should investigate where this comes from. > (Given that this is a public function, we should probably validate user > input; and maybe stop using AV_SAMPLE_FMT_NB altogether.) > > - Andreas > > _______________________________________________ > 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". _______________________________________________ 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".