From: Ian Jackson Date: Mon, 25 Apr 2016 01:45:49 +0000 (+0100) Subject: cgi-fcgi-interp: Fix logger buffer-handling bugs. X-Git-Tag: archive/debian/5.0.0~22 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=1d61e3a5e807c5356bfa4158c248013e3be788d4 cgi-fcgi-interp: Fix logger buffer-handling bugs. --- diff --git a/cprogs/cgi-fcgi-interp.c b/cprogs/cgi-fcgi-interp.c index 2c157d2..7a5a5db 100644 --- a/cprogs/cgi-fcgi-interp.c +++ b/cprogs/cgi-fcgi-interp.c @@ -789,12 +789,19 @@ static void errpipe_readable(void) { static char buf[1024]; static int pending; + /* %: does not contain newlines + * _: empty (garbage) + */ + + /* %%%%%%%%%%%__________________ */ + /* ^ pending */ + for (;;) { int avail = sizeof(buf) - pending; ssize_t got = read(errpipe, buf+pending, avail); if (got==-1) { if (errno==EINTR) continue; - else if (errno==EWOULDBLOCK || errno==EAGAIN) /*ok*/; + else if (errno==EWOULDBLOCK || errno==EAGAIN) return; else diee("(stage2) errpipe read"); got = 0; } else if (got==0) { @@ -819,6 +826,7 @@ static void errpipe_readable(void) { } syslog(LOG_ERR,"stderr: %.*s", printupto-eaten, buf+eaten); eaten += eat; + scanned = eaten; } pending -= eaten; memmove(buf, buf+eaten, pending); diff --git a/cprogs/cgi-fcgi-test b/cprogs/cgi-fcgi-test index 4c8d7b7..3d5f0ed 100755 --- a/cprogs/cgi-fcgi-test +++ b/cprogs/cgi-fcgi-test @@ -23,13 +23,15 @@ print STDERR "[$$ stderr starting]\n"; print REALSTDERR "[$$ real-stderr starting]\n"; while ($request->Accept >= 0) { + my $ua = $ENV{HTTP_USER_AGENT} // ''; print < Mon, 25 Apr 2016 02:45:44 +0100 + chiark-utils (4.5.0~iwj2) UNRELEASED; urgency=medium * cgi-fcgi-interp: mkdir ~/.cgi-fcgi-interp if necessary.