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 83D6E4566B for ; Sun, 14 May 2023 21:38:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8D50768BF7C; Mon, 15 May 2023 00:38:29 +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 7425B688318 for ; Mon, 15 May 2023 00:38:23 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id CAD07E0002 for ; Sun, 14 May 2023 21:38:22 +0000 (UTC) Date: Sun, 14 May 2023 23:38:22 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230514213822.GJ1391451@pb2> References: <20230512202622.29531-1-leo.izen@gmail.com> <20230513145422.GG1391451@pb2> <20230514204329.GI1391451@pb2> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avformat/hls: look for trailing GET headers with m3u8 extension check 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="===============2626618379500908077==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2626618379500908077== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Gnkm4uF329L9IN0W" Content-Disposition: inline --Gnkm4uF329L9IN0W Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 14, 2023 at 05:03:57PM -0400, Leo Izen wrote: >=20 >=20 > On 5/14/23 16:43, Michael Niedermayer wrote: > > On Sat, May 13, 2023 at 01:06:25PM -0400, Leo Izen wrote: > > >=20 > > >=20 > > > On 5/13/23 10:54, Michael Niedermayer wrote: > > > > On Fri, May 12, 2023 at 04:26:22PM -0400, Leo Izen wrote: > > > > > After commit 6b1f68ccb04d791f0250e05687c346a99ff47ea1 we refuse t= o use > > > > > URLs of the form https://foo.bar/baz.m3u8?foo=3Dbar because it fa= ils the > > > > > file extension check. This commit strips the ?foo=3Dbar at the en= d before > > > > > checking the file extension. > > > > >=20 > > > > > Signed-off-by: Leo Izen > > > > > --- > > > > > libavformat/hls.c | 11 ++++++++++- > > > > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > >=20 > > > > > diff --git a/libavformat/hls.c b/libavformat/hls.c > > > > > index 11e345b280..6a97cced17 100644 > > > > > --- a/libavformat/hls.c > > > > > +++ b/libavformat/hls.c > > > > > @@ -2534,7 +2534,16 @@ static int hls_probe(const AVProbeData *p) > > > > > strstr(p->buf, "#EXT-X-TARGETDURATION:") || > > > > > strstr(p->buf, "#EXT-X-MEDIA-SEQUENCE:")) { > > > > > - if (!av_match_ext(p->filename, "m3u8,hls,m3u")) { > > > > > + char *request_qmark =3D strchr(p->filename, '?'); > > > > > + int match_ext; > > > > > + > > > > > + if (request_qmark) > > > > > + *request_qmark =3D '\0'; > > > > > + match_ext =3D av_match_ext(p->filename, "m3u8,hls,m3u"); > > > > > + if (request_qmark) > > > > > + *request_qmark =3D '?'; > > > > > + > > > > > + if (!match_ext) { > > > > > av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls= with non standard extension\n"); > > > > > return 0; > > > > > } > > > >=20 > > > > the av_match_ext here matches the probe code > > > > all should be fixed. Also differences between local files and urls = should > > > > be considered in extension extraction > > >=20 > > > If you're requiring > >=20 > > That way you word this is a little odd > >=20 > >=20 > > > that we check that a file is local before stripping > > > tailing request headers, how would you check if a file is local? havi= ng a > > > scheme:// is not sufficient to make that check, as file:// is a valid > > > scheme. You could check for https?:// I suppose, but the spec doesn't > > > actually require that HTTP be used (section 2): > > >=20 > > > Data SHOULD be carried over HTTP [RFC7230], but, > > > in general, a URI can specify any protocol that can reliably tran= sfer > > > the specified resource on demand. > >=20 > > ATM the extension handling across the codebase treats everything like f= ilenames > > not like URIs, "?" has no special meaning. > > You add unconditional special meaning to "?" in one function ignoring > > everything else. I dont think thats improving the overall extension han= dling >=20 > Your ridiculous "security" check rejects files that have a .m3u8 extension > because of query strings. This is a bug, and it needs to be fixed. yes theres a bug and we should fix that bug >=20 > >=20 > > But lets consider: > > file:///home/myname/myfile.m3u8?file.avi > > /home/myname/myfile.m3u8?file.avi > > http:/server/myfile.m3u8?file.avi > >=20 > > The first is odd, iam not sure what "?file.avi" is and i wonder if we > > could simply reject this at file protocol level. >=20 > > If its accepted, I think it would map to /home/myname/myfile.m3u8 on di= sk > > not "/home/myname/myfile.m3u8?file.avi" >=20 >=20 > This is incorrect. Try it by naming a file "foo.m3u8?bar.txt" and run > xdg-open 'file:///home/leo/foo.m3u8?bar.txt' and you will find that it op= ens > it. What is incorrect ? we have some tools that will interpret "file:///home/leo/foo.m3u8?bar.txt" = as /home/leo/foo.m3u8?bar.txt and some /home/leo/foo.m3u8 on disk I think that makes that sort of file URLs ambigous, dont you agree ? thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates --Gnkm4uF329L9IN0W Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZGFUygAKCRBhHseHBAsP qy9XAJ99E9wBEjiSi8nVKgwtiWHvqQJOkQCfYhllmIbAD03xg+ImtVoSfpb0cUs= =PS88 -----END PGP SIGNATURE----- --Gnkm4uF329L9IN0W-- --===============2626618379500908077== 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". --===============2626618379500908077==--