From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Baines Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 1/2] web: Handle ending CRLF (\r\n) for chunked input and output ports. Date: Mon, 04 Jul 2022 12:37:05 +0100 Message-ID: <875ykd6r9w.fsf@cbaines.net> References: <20220630181554.25772-1-mail@cbaines.net> <87o7y5fbjg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23587"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 28.1 Cc: guile-devel@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Mon Jul 04 13:42:13 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8KSz-0005vX-Fd for guile-devel@m.gmane-mx.org; Mon, 04 Jul 2022 13:42:13 +0200 Original-Received: from localhost ([::1]:35382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8KSy-0008CS-3X for guile-devel@m.gmane-mx.org; Mon, 04 Jul 2022 07:42:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8KQO-0006bN-Po for guile-devel@gnu.org; Mon, 04 Jul 2022 07:39:32 -0400 Original-Received: from mira.cbaines.net ([212.71.252.8]:36622) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8KQM-00015z-CZ; Mon, 04 Jul 2022 07:39:32 -0400 Original-Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id BD1DE27BBE9; Mon, 4 Jul 2022 12:39:26 +0100 (BST) Original-Received: from felis (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id c2b78667; Mon, 4 Jul 2022 11:39:25 +0000 (UTC) In-reply-to: <87o7y5fbjg.fsf@gnu.org> Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21251 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > Christopher Baines skribis: > >> The chunked transfer encoding specifies the chunked body ends with >> CRLF. This is in addition to the CRLF at the end of the last chunk, so >> there should be CRLF twice at the end of the chunked body: >> >> https://datatracker.ietf.org/doc/html/rfc2616#section-3.6.1 >> >> * module/web/http.scm (make-chunked-input-port): Read two extra bytes at >> the end of the chunked input. >> (make-chunked-output-port): Write the missing \r\n when closing the >> port. >> * test-suite/tests/web-http.test (chunked encoding): Add missing \r\n to >> test data. > > [...] > >> This port is of limited use if it cannot be used reliably. Rather than >> behaving as if the input has finished when it ends unexpectedly, instead >> raise an exception. >> >> * module/web/http.scm (make-chunked-input-port): Raise an exception on >> premature termination. >> (&chunked-input-ended-prematurely): New exception type. >> (chunked-input-ended-prematurely-error?): New procedure. >> * test-suite/tests/web-http.test (pass-if-named-exception): Rename to >> pass-if-named-exception. >> (pass-if-named-exception): New syntax. >> ("Exception on premature chunk end"): New test for this behaviour. > > Applied, thanks! Awesome :) > Are there servers out there where you would hit this bug? We were > =E2=80=9Clucky=E2=80=9D not to notice before I guess. I'm unsure. I think I first hit this on the make-chunked-input-port side with the Guix Build Coordinator. I can't remember the details, but I was doing some testing with curl at least, and that behaved differently: https://git.cbaines.net/guix/build-coordinator/commit/?id=3D3ee79ba7b6832= 75ef066f4d61b1ce50b64bd19ac --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmLC0WtfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh aW5lcy5uZXQACgkQXiijOwuE9Xd3jg//dqnpSVWzuGA8xTm40C5GTEUWm2mJMClC UPxWtCOXZI6zK7PU+3l1dlyKjLnEjmk+oR1BDRUbTlrzO21pk+3M3ocJxZ2eYZxu ZH13/o01ud346XFcfXAd2/+kBMueyaDut8otwXg36yIUjpSeXlZyJBBrWW7OOQe1 ilIfFFKKFStOUslo4qG33qAswLKKuyvZR++schK05LGpG8gRAx0JqAHgwuTX0Xo6 SIL7pImYmQWpJMBkxsxRPVuZmv3rInOsiM5yW8RaPHoVdxsl47TdmehfWtujwLP8 +spDOKrK/gQMc/So0LFEXZymz8AddTxeMUt0WhZlu4aZSHmFixWB3CJ7uegPm6zb YqVTuabj2xYhVoZbDm5fGGOmFCK3rBK3lbICDydWSBxa6aaGXGrT2z8+abhASl25 KTo0iCr25+n4O89y/IUhxM6APCbX6GYc2b26QyNiauNlZ39s5XvSMLr1UhBOWgks FJ3QaomQzPytWXQz51A83OuAGFcyw8UHK/1xoWBjVmUjoC8k8BjCNTtYSBrgAnI0 OHS9MNIP6UX17xF7YNO3bK663ghC8k+airLV61mX30F7yooCeSGHLtGbAQFGJW9F Wqhk/yRxNTniSJF5sKF66kAdbWPDle5EiyI8IU9e3+eWF/VbTNKS7aEv7a5I8/xo 1HUZ9YY7kUw= =wbYy -----END PGP SIGNATURE----- --=-=-=--