user/dev discussion of public-inbox itself
 help / color / Atom feed
* [PATCH] t/httpd-corner: ensure chunk payload read doesn't overreach
@ 2019-06-20  1:16 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2019-06-20  1:16 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20  1:16 [PATCH] t/httpd-corner: ensure chunk payload read doesn't overreach Eric Wong

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox