From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 75AA11F462 for ; Thu, 20 Jun 2019 01:16:36 +0000 (UTC) From: Eric Wong 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 Message-Id: <20190620011636.6030-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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