Revert package feed back
[librecmc/package-feed.git] / net / lighttpd / patches / 0003-mod_cgi-status-200-OK-if-no-hdrs-deprecated-2786.patch
1 From 51ff7ac504f7001dc54807f9b2a72de891ab9ee5 Mon Sep 17 00:00:00 2001
2 From: Glenn Strauss <gstrauss@gluelogic.com>
3 Date: Wed, 22 Feb 2017 11:58:21 -0500
4 Subject: [PATCH] [mod_cgi] status 200 OK if no hdrs (deprecated) (#2786)
5
6 set status 200 OK if CGI does not return CGI headers
7
8 Note:
9 This mode in lighttpd is deprecated and may be removed in the next major
10 release of lighttpd.  CGI scripts should return a proper CGI header in
11 the response, even if that header is empty and followed by a blank line,
12 before return response body.
13
14 Without a proper CGI response header, the first line(s) of the response
15 might be incorrectly construed as being CGI response headers, especially
16 if they contain ':', and response may be corrupted.  That is why this
17 mode is deprecated (and not supported in numerous other web servers).
18
19 The minimal valid CGI response header is "\n", which lighttpd will treat
20 as equivalent to "Status: 200\n\n"
21
22 x-ref:
23   "error 500 (mod_cgi.c.601) cgi died"
24   https://redmine.lighttpd.net/issues/2786
25 ---
26  src/mod_cgi.c | 2 ++
27  1 file changed, 2 insertions(+)
28
29 --- a/src/mod_cgi.c
30 +++ b/src/mod_cgi.c
31 @@ -502,6 +502,7 @@ static int cgi_demux_response(server *sr
32                                         if (0 != http_chunk_append_buffer(srv, con, hctx->response_header)) {
33                                                 return FDEVENT_HANDLED_ERROR;
34                                         }
35 +                                       if (0 == con->http_status) con->http_status = 200; /* OK */
36                                 } else {
37                                         const char *bstart;
38                                         size_t blen;
39 @@ -846,6 +847,7 @@ static handler_t cgi_handle_fdevent(serv
40                                 cgi_connection_close(srv, hctx);
41                                 return HANDLER_ERROR;
42                         }
43 +                       if (0 == con->http_status) con->http_status = 200; /* OK */
44                 } else {
45  # if 0
46                         log_error_write(srv, __FILE__, __LINE__, "sddd", "got HUP from cgi", con->fd, hctx->fd, revents);