httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Korthof ...@organic.com>
Subject [PATCH] logging BAD_REQUESTS in the proxy module
Date Sun, 10 Aug 1997 02:19:03 GMT
This patch adds a bit of logging any time the proxy module returns
BAD_REQUEST (== HTTP_BAD_REQUEST).  I've used log_reason, assuming it's
not depriciated (the few patches re: the new logging levels appear to
suggest) -- if that's not the case, what should I use?  I've gone through
the code and attempted to give good explanations, but if anyone wants to
offer better ones, feel free (I wasn't too sure in a couple of the
places). 

Anyway, this is a context diff (my diff utility doesn't seem to offer an
option for unified diffs) -- what package (for Solaris) could I get which
would allow unified diffs?

Btw, thanks, Marc, for the information about how to get to /from-cvs/.
:)

     -- Ed Korthof        |  Web Server Engineer --
     -- ed@organic.com    |  Organic Online, Inc --
     -- (415) 278-5676    |  Fax: (415) 284-6891 --

*** mod_proxy.c.orig	Sat Aug  9 18:20:40 1997
--- mod_proxy.c	Sat Aug  9 19:09:10 1997
***************
*** 170,174 ****
  /* lowercase the scheme */
      p = strchr(url, ':');
!     if (p == NULL || p == url) return BAD_REQUEST;
      for (i=0; i != p - url; i++) url[i] = tolower(url[i]);
  
--- 170,178 ----
  /* lowercase the scheme */
      p = strchr(url, ':');
!     if (p == NULL || p == url) {
!         log_reason ("null protocol or no protocol in proxy fixup",
!                     r->filename, r);
!         return BAD_REQUEST;
!     }
      for (i=0; i != p - url; i++) url[i] = tolower(url[i]);
  
***************
*** 281,285 ****
      url = r->filename + 6;
      p = strchr(url, ':');
!     if (p == NULL) return BAD_REQUEST;
  
      rc = proxy_cache_check(r, url, &conf->cache, &cr);
--- 285,293 ----
      url = r->filename + 6;
      p = strchr(url, ':');
!     if (p == NULL) {
!         log_reason ("null protocol or no protocol in proxy handler",
!                     r->filename, r);
!         return BAD_REQUEST;
!     }
  
      rc = proxy_cache_check(r, url, &conf->cache, &cr);
*** proxy_ftp.c.orig	Sat Aug  9 18:20:48 1997
--- proxy_ftp.c	Sat Aug  9 19:13:04 1997
***************
*** 56,59 ****
--- 56,60 ----
  #include "http_main.h"
  #include "mod_mime.h"
+ #include "http_log.h"
  
  /*
***************
*** 116,122 ****
      port = DEFAULT_FTP_PORT;
      err = proxy_canon_netloc(pool, &url, &user, &password, &host, &port);
!     if (err) return BAD_REQUEST;
!     if (user != NULL && !ftp_check_string(user)) return BAD_REQUEST;
!     if (password != NULL && !ftp_check_string(password)) return BAD_REQUEST;
  
  /* now parse path/parameters args, according to rfc1738 */
--- 117,133 ----
      port = DEFAULT_FTP_PORT;
      err = proxy_canon_netloc(pool, &url, &user, &password, &host, &port);
!     if (err) {
!         log_reason (err, r->filename, r);
!         return BAD_REQUEST;
!     }
!     if (user != NULL && !ftp_check_string(user)) {
!         log_reason ("invalid user string in ftp proxy request", r->filename, r);
!         return BAD_REQUEST;
!     }
!     if (password != NULL && !ftp_check_string(password)) {
!         log_reason ("invalid password string in ftp proxy request",
!                     r->filename, r);
!         return BAD_REQUEST;
!     }
  
  /* now parse path/parameters args, according to rfc1738 */
***************
*** 131,135 ****
  	*(p++) = '\0';
  	parms = proxy_canonenc(pool, p, strlen(p), enc_parm, r->proxyreq);
! 	if (parms == NULL) return BAD_REQUEST;
      } else
  	parms = "";
--- 142,150 ----
  	*(p++) = '\0';
  	parms = proxy_canonenc(pool, p, strlen(p), enc_parm, r->proxyreq);
! 	if (parms == NULL) {
!             log_reason ("invalid parameters in ftp proxy request",
!                         r->filename, r);
!             return BAD_REQUEST;
!         }
      } else
  	parms = "";
***************
*** 136,141 ****
  
      path = proxy_canonenc(pool, url, strlen(url), enc_path, r->proxyreq);
!     if (path == NULL) return BAD_REQUEST;
!     if (!ftp_check_string(path)) return BAD_REQUEST;
  
      if (!r->proxyreq && r->args != NULL)
--- 151,162 ----
  
      path = proxy_canonenc(pool, url, strlen(url), enc_path, r->proxyreq);
!     if (path == NULL) {
!         log_reason ("bad path in ftp proxy URL", r->filename, r);
!         return BAD_REQUEST;
!     }
!     if (!ftp_check_string(path)) {
!         log_reason ("invalid characters in ftp proxy path", r->filename, r);
!         return BAD_REQUEST;
!     }
  
      if (!r->proxyreq && r->args != NULL)
***************
*** 144,148 ****
  	{
  	    p = proxy_canonenc(pool, r->args, strlen(r->args), enc_parm, 1);
! 	    if (p == NULL) return BAD_REQUEST;
  	    parms = pstrcat(pool, parms, "?", p, NULL);
  	}
--- 165,173 ----
  	{
  	    p = proxy_canonenc(pool, r->args, strlen(r->args), enc_parm, 1);
! 	    if (p == NULL) {
!                 log_reason ("bad string in ftp proxy (looking for parameters)",
!                             r->filename, r);
!                 return BAD_REQUEST;
!             }
  	    parms = pstrcat(pool, parms, "?", p, NULL);
  	}
***************
*** 150,154 ****
  	{
  	    p = proxy_canonenc(pool, r->args, strlen(r->args), enc_fpath, 1);
! 	    if (p == NULL) return BAD_REQUEST;
  	    path = pstrcat(pool, path, "?", p, NULL);
  	}
--- 175,183 ----
  	{
  	    p = proxy_canonenc(pool, r->args, strlen(r->args), enc_fpath, 1);
! 	    if (p == NULL) {
!                 log_reason ("bad string in ftp proxy (looking for a path)",
!                             r->filename, r);
!                 return BAD_REQUEST;
!             }
  	    path = pstrcat(pool, path, "?", p, NULL);
  	}
*** proxy_http.c.orig	Sat Aug  9 18:20:58 1997
--- proxy_http.c	Sat Aug  9 18:42:33 1997
***************
*** 76,80 ****
      port = def_port;
      err = proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
!     if (err) return BAD_REQUEST;
  
  /* now parse path/search args, according to rfc1738 */
--- 76,83 ----
      port = def_port;
      err = proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
!     if (err) {
!         log_reason (err, r->filename, r);
!         return BAD_REQUEST;
!     }
  
  /* now parse path/search args, according to rfc1738 */
***************
*** 91,95 ****
  /* process path */
      path = proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
!     if (path == NULL) return BAD_REQUEST;
  
  /* process search */
--- 94,101 ----
  /* process path */
      path = proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
!     if (path == NULL) {
!         log_reason ("null/invalid path in http proxy", r->filename, r);
!         return BAD_REQUEST;
!     }
  
  /* process search */
***************
*** 97,101 ****
      {
  	search = p;
! 	if (search == NULL) return BAD_REQUEST;
      } else
  	search = NULL;
--- 103,111 ----
      {
  	search = p;
! 	if (search == NULL) {
!             log_reason ("null/invalid string in process search, in http proxy",
!                         r->filename, r);
!             return BAD_REQUEST;
!         }
      } else
  	search = NULL;



Mime
View raw message