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 012F2435F1 for ; Sat, 18 Jun 2022 16:18:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6D0F568B587; Sat, 18 Jun 2022 19:18:23 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0210368B3F4 for ; Sat, 18 Jun 2022 19:18:16 +0300 (EEST) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 4A006E0003 for ; Sat, 18 Jun 2022 16:18:15 +0000 (UTC) Date: Sat, 18 Jun 2022 18:18:14 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220618161814.GY396728@pb2> References: <20220208202353.19554-1-michael@niedermayer.cc> <20220208202353.19554-2-michael@niedermayer.cc> <7e97fc0-25ab-7ba8-ece8-a9e75f60a120@passwd.hu> MIME-Version: 1.0 In-Reply-To: <7e97fc0-25ab-7ba8-ece8-a9e75f60a120@passwd.hu> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in avformat_find_stream_info() 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="===============1808280912632778988==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1808280912632778988== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="m2hhT81AZMAdw9a5" Content-Disposition: inline --m2hhT81AZMAdw9a5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 17, 2022 at 10:15:39PM +0200, Marton Balint wrote: >=20 >=20 > On Tue, 8 Feb 2022, Michael Niedermayer wrote: >=20 > > Fixes: Timeout > > Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-52= 06008287330304 > >=20 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz= /tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/demux.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > >=20 > > diff --git a/libavformat/demux.c b/libavformat/demux.c > > index dd42d32710..1acba0c608 100644 > > --- a/libavformat/demux.c > > +++ b/libavformat/demux.c > > @@ -2590,8 +2590,10 @@ int avformat_find_stream_info(AVFormatContext *i= c, AVDictionary **options) > > /* NOTE: A new stream can be added there if no header in file > > * (AVFMTCTX_NOHEADER). */ > > ret =3D read_frame_internal(ic, pkt1); > > - if (ret =3D=3D AVERROR(EAGAIN)) > > + if (ret =3D=3D AVERROR(EAGAIN)) { > > + read_size +=3D 100; >=20 > Sorry, same here, very hackish. I especially dislike that you use read_si= ze > for a limit because that intereferes with probesize and silently ignores = the > problem. >=20 > Can't we fix the underlying issue? If not, then counting the number of > EAGAINs and returning a hard failure if that becomes more than e.g. 10000 > would be a lot more acceptable to me. E.g. >=20 > if (nb_egains > 10000) { > av_log(NULL, AV_LOG_ERROR, "read_frame stuck in an EAGAIN loop, this s= hould not happen\n); > return AVERROR_BUG; > } I dont know if AVERROR_BUG is the correct return code. Also with this the question is do you reset nb_egains after a non zero outp= ut or not ? if you do then you could have a case where there are 9999 empty packets=20 followed by 1 byte followed by 9999 empty packets ... if you do not then a file with 10001 1 byte packets where after each theres= 1 empty one would fail Surely these are constructed hypothetical cases but the idea of adding it with the number of reads is so that the real "cost" is bound maybe a sepertate nb_egains tahts non reseting could be done but with a lar= ger limit I dont really have an opinion on this, i dont like mixing it in read_size either but then i also dont like any other solution. needing an extra threshold and potentially user setable parameter all suck too so if you like this nb_egains code better, sure go ahead and replace it thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact --m2hhT81AZMAdw9a5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYq36wwAKCRBhHseHBAsP qylSAJ4tcO5t/OYDzP3MTGp2XOGIU0DmuACfRlEimOpp8NCFWmQ9VnrhUoOCTl0= =IP0T -----END PGP SIGNATURE----- --m2hhT81AZMAdw9a5-- --===============1808280912632778988== 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". --===============1808280912632778988==--