From: Eric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Date: Tue, 27 Mar 2018 20:24:21 +0000 (+0000)
Subject: githttpbackend: avoid infinite loop on generic PSGI servers
X-Git-Tag: v1.1.0-pre1~117
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a966564fef08a4f25670778efbff139fbbf47c84;p=public-inbox.git

githttpbackend: avoid infinite loop on generic PSGI servers

We must detect EOF when reading a POST body with standard PSGI servers.
This does not affect deployments using the standard public-inbox-httpd;
but most smaller inboxes should be able to get away using a generic
PSGI server.
---

diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index 4d2816a0..6efe5b31 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -280,6 +280,7 @@ sub input_to_file {
 			err($env, "error reading input: $!");
 			return;
 		}
+		last if $r == 0;
 		my $off = 0;
 		while ($r > 0) {
 			my $w = syswrite($in, $buf, $r, $off);