Fix two cases in which an invalid server response would result
authorFabian Keil <fk@fabiankeil.de>
Thu, 9 Apr 2009 10:12:54 +0000 (10:12 +0000)
committerFabian Keil <fk@fabiankeil.de>
Thu, 9 Apr 2009 10:12:54 +0000 (10:12 +0000)
in the client connection being closed without sending an error
message first.

jcc.c

diff --git a/jcc.c b/jcc.c
index 390408e..8fb4e60 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.238 2009/03/27 14:42:30 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.239 2009/04/07 11:43:50 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -33,6 +33,11 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.238 2009/03/27 14:42:30 fabiankeil Exp $"
  *
  * Revisions   :
  *    $Log: jcc.c,v $
+ *    Revision 1.239  2009/04/07 11:43:50  fabiankeil
+ *    If the server rudely resets the connection directly after sending the
+ *    headers, pass the mess to the client instead of sending an incorrect
+ *    connect-failed message. Fixes #2698674 reported by mybugaccount.
+ *
  *    Revision 1.238  2009/03/27 14:42:30  fabiankeil
  *    Correct the status code for CONNECTION_TIMEOUT_RESPONSE.
  *
@@ -3180,9 +3185,14 @@ static void chat(struct client_state *csp)
                    * The header is incomplete and there isn't anything
                    * we can do about it.
                    */
-                  log_error(LOG_LEVEL_INFO,
-                     "MS IIS5 hack didn't produce valid headers.");
-                  break;
+                  log_error(LOG_LEVEL_ERROR, "Invalid server headers. "
+                     "Applying the MS IIS5 hack didn't help.");
+                  log_error(LOG_LEVEL_CLF,
+                     "%s - - [%T] \"%s\" 502 0", csp->ip_addr_str, http->cmd);
+                  write_socket(csp->cfd, INVALID_SERVER_HEADERS_RESPONSE,
+                     strlen(INVALID_SERVER_HEADERS_RESPONSE));
+                  mark_server_socket_tainted(csp);
+                  return;
                }
                else
                {
@@ -3319,9 +3329,15 @@ static void chat(struct client_state *csp)
              */
             if (ms_iis5_hack)
             {
-               log_error(LOG_LEVEL_INFO,
-                  "Closed server connection detected with MS IIS5 hack enabled.");
-               break;
+               log_error(LOG_LEVEL_ERROR,
+                  "Closed server connection detected. "
+                  "Applying the MS IIS5 hack didn't help.");
+               log_error(LOG_LEVEL_CLF,
+                  "%s - - [%T] \"%s\" 502 0", csp->ip_addr_str, http->cmd);
+               write_socket(csp->cfd, INVALID_SERVER_HEADERS_RESPONSE,
+                  strlen(INVALID_SERVER_HEADERS_RESPONSE));
+               mark_server_socket_tainted(csp);
+               return;
             }
          }
          continue;