-const char jcc_rcs[] = "$Id: jcc.c,v 1.172 2008/04/16 16:38:21 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.175 2008/05/09 18:53:59 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.175 2008/05/09 18:53:59 fabiankeil
+ * Fix comment grammar.
+ *
+ * Revision 1.174 2008/05/07 18:05:53 fabiankeil
+ * Remove the pointless buffer in client_protocol_is_unsupported().
+ *
+ * Revision 1.173 2008/05/06 15:09:00 fabiankeil
+ * Least-effort fix for bug #1821930 (reported by Lee):
+ * If the response doesn't look like HTTP,
+ * tell the client and log the problem.
+ *
* Revision 1.172 2008/04/16 16:38:21 fabiankeil
* Don't pass the whole csp structure to flush_socket()
* when it only needs a file descriptor and a buffer.
*********************************************************************/
static int client_protocol_is_unsupported(const struct client_state *csp, char *req)
{
- char buf[BUFFER_SIZE];
-
/*
* If it's a FTP or gopher request, we don't support it.
*
*/
if (!strncmpic(req, "GET ftp://", 10) || !strncmpic(req, "GET gopher://", 13))
{
+ const char *response = NULL;
+ const char *protocol = NULL;
+
if (!strncmpic(req, "GET ftp://", 10))
{
- strlcpy(buf, FTP_RESPONSE, sizeof(buf));
- log_error(LOG_LEVEL_ERROR, "%s tried to use Privoxy as FTP proxy: %s",
- csp->ip_addr_str, req);
+ response = FTP_RESPONSE;
+ protocol = "FTP";
}
else
{
- strlcpy(buf, GOPHER_RESPONSE, sizeof(buf));
- log_error(LOG_LEVEL_ERROR, "%s tried to use Privoxy as gopher proxy: %s",
- csp->ip_addr_str, req);
+ response = GOPHER_RESPONSE;
+ protocol = "GOPHER";
}
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 400 0", csp->ip_addr_str, req);
+ log_error(LOG_LEVEL_ERROR,
+ "%s tried to use Privoxy as %s proxy: %s",
+ csp->ip_addr_str, protocol, req);
+ log_error(LOG_LEVEL_CLF,
+ "%s - - [%T] \"%s\" 400 0", csp->ip_addr_str, req);
freez(req);
- write_socket(csp->cfd, buf, strlen(buf));
+ write_socket(csp->cfd, response, strlen(response));
return TRUE;
}
return JB_ERR_PARSE;
}
- /* Enlist header */
if (JB_ERR_MEMORY == enlist(csp->headers, header))
{
/*
* This is NOT the body, so
* Let's pretend the server just sent us a blank line.
*/
- log_error(LOG_LEVEL_INFO,
- "Malformerd HTTP headers detected and MS IIS5 hack enabled. "
- "Expect an invalid response or even no response at all.");
snprintf(buf, sizeof(buf), "\r\n");
len = (int)strlen(buf);
* and there isn't anything
* we can do about it.
*/
+ log_error(LOG_LEVEL_INFO,
+ "MS IIS5 hack didn't produce valid headers.");
break;
}
else
*/
if (ms_iis5_hack)
{
+ log_error(LOG_LEVEL_INFO,
+ "Closed server connection detected with MS IIS5 hack enabled.");
break;
}
}
* Parse the command line arguments
*
* XXX: simply printing usage information in case of
- * invalid arguments isn't particular user friendly.
+ * invalid arguments isn't particularly user friendly.
*/
while (++argc_pos < argc)
{