user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] t/httpd-corner: ensure chunk payload read doesn't overreach
Date: Thu, 20 Jun 2019 01:16:36 +0000	[thread overview]
Message-ID: <20190620011636.6030-1-e@80x24.org> (raw)

It never has, AFAIK, but I'm making some changes to this code in
another branch and nearly introduced a bug where it would be
overreading and discarding the pipelined request.
---
 t/httpd-corner.t | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 56e5a5bc..c1dc77db 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -123,6 +123,21 @@ my $spawn_httpd = sub {
 	like($head, qr/\b413\b/, 'got 413 response');
 }
 
+{
+	my $conn = conn_for($sock, 'chunk with pipeline');
+	my $n = 10;
+	my $payload = 'b'x$n;
+	$conn->write("PUT /sha1 HTTP/1.1\r\nTransfer-Encoding: chunked\r\n");
+	$conn->write("\r\n".sprintf("%x\r\n", $n));
+	$conn->write($payload . "\r\n0\r\n\r\nGET /empty HTTP/1.0\r\n\r\n");
+	$conn->read(my $buf, 4096);
+	my $lim = 0;
+	$lim++ while ($conn->read($buf, 4096, bytes::length($buf)) && $lim < 9);
+	my $exp = sha1_hex($payload);
+	like($buf, qr!\r\n\r\n${exp}HTTP/1\.0 200 OK\r\n!s,
+		'chunk parser can handled pipelined requests');
+}
+
 # Unix domain sockets
 {
 	my $u = IO::Socket::UNIX->new(Type => SOCK_STREAM, Peer => $upath);
-- 
EW


                 reply	other threads:[~2019-06-20  1:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190620011636.6030-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).