You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ed Korthof <ed...@organic.com> on 1997/08/13 08:29:00 UTC
[PATCH] proxy logging, take 2
Done as a unified diff, w/ Marc's suggestion of changing BAD_REQUEST to
HTTP_BAD_REQUEST.
Some of the explanations are obscure, but they're better than nothing (at
least they'll tell you exactly where in the source code to look) -- and
some of them are quite useful (including those which are put into a string
'err' -- which is not currently getting logged anywhere I can find it).
-- 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 23:15:12 1997
@@ -169,7 +169,11 @@
url = &r->filename[6];
/* lowercase the scheme */
p = strchr(url, ':');
- if (p == NULL || p == url) return BAD_REQUEST;
+ if (p == NULL || p == url) {
+ log_reason("null protocol or no protocol in proxy fixup",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
for (i=0; i != p - url; i++) url[i] = tolower(url[i]);
/* canonicalise each specific scheme */
@@ -280,7 +284,11 @@
url = r->filename + 6;
p = strchr(url, ':');
- if (p == NULL) return BAD_REQUEST;
+ if (p == NULL) {
+ log_reason ("null protocol or no protocol in proxy handler",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
rc = proxy_cache_check(r, url, &conf->cache, &cr);
if (rc != DECLINED) return rc;
--- proxy_ftp.c.orig Sat Aug 9 18:20:48 1997
+++ proxy_ftp.c Sat Aug 9 23:15:27 1997
@@ -55,6 +55,7 @@
#include "mod_proxy.h"
#include "http_main.h"
#include "mod_mime.h"
+#include "http_log.h"
/*
* Decodes a '%' escaped string, and returns the number of characters
@@ -115,9 +116,19 @@
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;
+ if (err) {
+ log_reason (err, r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
+ if (user != NULL && !ftp_check_string(user)) {
+ log_reason ("invalid user string in ftp proxy request", r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
+ if (password != NULL && !ftp_check_string(password)) {
+ log_reason ("invalid password string in ftp proxy request",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
/* now parse path/parameters args, according to rfc1738 */
/* N.B. if this isn't a true proxy request, then the URL path
@@ -130,26 +141,44 @@
{
*(p++) = '\0';
parms = proxy_canonenc(pool, p, strlen(p), enc_parm, r->proxyreq);
- if (parms == NULL) return BAD_REQUEST;
+ if (parms == NULL) {
+ log_reason ("invalid parameters in ftp proxy request",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
} else
parms = "";
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 (path == NULL) {
+ log_reason ("bad path in ftp proxy URL", r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
+ if (!ftp_check_string(path)) {
+ log_reason ("invalid characters in ftp proxy path", r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
if (!r->proxyreq && r->args != NULL)
{
if (p != NULL)
{
p = proxy_canonenc(pool, r->args, strlen(r->args), enc_parm, 1);
- if (p == NULL) return BAD_REQUEST;
+ if (p == NULL) {
+ log_reason ("bad string in ftp proxy (looking for parameters)",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
parms = pstrcat(pool, parms, "?", p, NULL);
}
else
{
p = proxy_canonenc(pool, r->args, strlen(r->args), enc_fpath, 1);
- if (p == NULL) return BAD_REQUEST;
+ if (p == NULL) {
+ log_reason ("bad string in ftp proxy (looking for a path)",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
path = pstrcat(pool, path, "?", p, NULL);
}
r->args = NULL;
--- proxy_http.c.orig Sat Aug 9 18:20:58 1997
+++ proxy_http.c Sat Aug 9 23:15:38 1997
@@ -75,7 +75,10 @@
*/
port = def_port;
err = proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
- if (err) return BAD_REQUEST;
+ if (err) {
+ log_reason (err, r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
/* now parse path/search args, according to rfc1738 */
/* N.B. if this isn't a true proxy request, then the URL _path_
@@ -90,13 +93,20 @@
/* process path */
path = proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
- if (path == NULL) return BAD_REQUEST;
+ if (path == NULL) {
+ log_reason ("null/invalid path in http proxy", r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
/* process search */
if (p != NULL)
{
search = p;
- if (search == NULL) return BAD_REQUEST;
+ if (search == NULL) {
+ log_reason ("null/invalid string in process search, in http proxy",
+ r->filename, r);
+ return HTTP_BAD_REQUEST;
+ }
} else
search = NULL;
Re: [PATCH] proxy logging, take 2
Posted by Marc Slemko <ma...@worldgate.com>.
You also need to include http_log.h in proxy_ftp.h.
Interesting that mod_proxy has its own logging function (proxy_log_uerror)
that writes directly to the logs.
On Sat, 16 Aug 1997, Marc Slemko wrote:
> +1.
>
> On Tue, 12 Aug 1997, Ed Korthof wrote:
>
> > Done as a unified diff, w/ Marc's suggestion of changing BAD_REQUEST to
> > HTTP_BAD_REQUEST.
> >
> > Some of the explanations are obscure, but they're better than nothing (at
> > least they'll tell you exactly where in the source code to look) -- and
> > some of them are quite useful (including those which are put into a string
> > 'err' -- which is not currently getting logged anywhere I can find it).
> >
> > -- 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 23:15:12 1997
> > @@ -169,7 +169,11 @@
> > url = &r->filename[6];
> > /* lowercase the scheme */
> > p = strchr(url, ':');
> > - if (p == NULL || p == url) return BAD_REQUEST;
> > + if (p == NULL || p == url) {
> > + log_reason("null protocol or no protocol in proxy fixup",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > for (i=0; i != p - url; i++) url[i] = tolower(url[i]);
> >
> > /* canonicalise each specific scheme */
> > @@ -280,7 +284,11 @@
> >
> > url = r->filename + 6;
> > p = strchr(url, ':');
> > - if (p == NULL) return BAD_REQUEST;
> > + if (p == NULL) {
> > + log_reason ("null protocol or no protocol in proxy handler",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> >
> > rc = proxy_cache_check(r, url, &conf->cache, &cr);
> > if (rc != DECLINED) return rc;
> > --- proxy_ftp.c.orig Sat Aug 9 18:20:48 1997
> > +++ proxy_ftp.c Sat Aug 9 23:15:27 1997
> > @@ -55,6 +55,7 @@
> > #include "mod_proxy.h"
> > #include "http_main.h"
> > #include "mod_mime.h"
> > +#include "http_log.h"
> >
> > /*
> > * Decodes a '%' escaped string, and returns the number of characters
> > @@ -115,9 +116,19 @@
> >
> > 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;
> > + if (err) {
> > + log_reason (err, r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > + if (user != NULL && !ftp_check_string(user)) {
> > + log_reason ("invalid user string in ftp proxy request", r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > + if (password != NULL && !ftp_check_string(password)) {
> > + log_reason ("invalid password string in ftp proxy request",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> >
> > /* now parse path/parameters args, according to rfc1738 */
> > /* N.B. if this isn't a true proxy request, then the URL path
> > @@ -130,26 +141,44 @@
> > {
> > *(p++) = '\0';
> > parms = proxy_canonenc(pool, p, strlen(p), enc_parm, r->proxyreq);
> > - if (parms == NULL) return BAD_REQUEST;
> > + if (parms == NULL) {
> > + log_reason ("invalid parameters in ftp proxy request",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > } else
> > parms = "";
> >
> > 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 (path == NULL) {
> > + log_reason ("bad path in ftp proxy URL", r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > + if (!ftp_check_string(path)) {
> > + log_reason ("invalid characters in ftp proxy path", r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> >
> > if (!r->proxyreq && r->args != NULL)
> > {
> > if (p != NULL)
> > {
> > p = proxy_canonenc(pool, r->args, strlen(r->args), enc_parm, 1);
> > - if (p == NULL) return BAD_REQUEST;
> > + if (p == NULL) {
> > + log_reason ("bad string in ftp proxy (looking for parameters)",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > parms = pstrcat(pool, parms, "?", p, NULL);
> > }
> > else
> > {
> > p = proxy_canonenc(pool, r->args, strlen(r->args), enc_fpath, 1);
> > - if (p == NULL) return BAD_REQUEST;
> > + if (p == NULL) {
> > + log_reason ("bad string in ftp proxy (looking for a path)",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > path = pstrcat(pool, path, "?", p, NULL);
> > }
> > r->args = NULL;
> > --- proxy_http.c.orig Sat Aug 9 18:20:58 1997
> > +++ proxy_http.c Sat Aug 9 23:15:38 1997
> > @@ -75,7 +75,10 @@
> > */
> > port = def_port;
> > err = proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
> > - if (err) return BAD_REQUEST;
> > + if (err) {
> > + log_reason (err, r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> >
> > /* now parse path/search args, according to rfc1738 */
> > /* N.B. if this isn't a true proxy request, then the URL _path_
> > @@ -90,13 +93,20 @@
> >
> > /* process path */
> > path = proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
> > - if (path == NULL) return BAD_REQUEST;
> > + if (path == NULL) {
> > + log_reason ("null/invalid path in http proxy", r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> >
> > /* process search */
> > if (p != NULL)
> > {
> > search = p;
> > - if (search == NULL) return BAD_REQUEST;
> > + if (search == NULL) {
> > + log_reason ("null/invalid string in process search, in http proxy",
> > + r->filename, r);
> > + return HTTP_BAD_REQUEST;
> > + }
> > } else
> > search = NULL;
> >
> >
> >
>
Re: [PATCH] proxy logging, take 2
Posted by Marc Slemko <ma...@worldgate.com>.
+1.
On Tue, 12 Aug 1997, Ed Korthof wrote:
> Done as a unified diff, w/ Marc's suggestion of changing BAD_REQUEST to
> HTTP_BAD_REQUEST.
>
> Some of the explanations are obscure, but they're better than nothing (at
> least they'll tell you exactly where in the source code to look) -- and
> some of them are quite useful (including those which are put into a string
> 'err' -- which is not currently getting logged anywhere I can find it).
>
> -- 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 23:15:12 1997
> @@ -169,7 +169,11 @@
> url = &r->filename[6];
> /* lowercase the scheme */
> p = strchr(url, ':');
> - if (p == NULL || p == url) return BAD_REQUEST;
> + if (p == NULL || p == url) {
> + log_reason("null protocol or no protocol in proxy fixup",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> for (i=0; i != p - url; i++) url[i] = tolower(url[i]);
>
> /* canonicalise each specific scheme */
> @@ -280,7 +284,11 @@
>
> url = r->filename + 6;
> p = strchr(url, ':');
> - if (p == NULL) return BAD_REQUEST;
> + if (p == NULL) {
> + log_reason ("null protocol or no protocol in proxy handler",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
>
> rc = proxy_cache_check(r, url, &conf->cache, &cr);
> if (rc != DECLINED) return rc;
> --- proxy_ftp.c.orig Sat Aug 9 18:20:48 1997
> +++ proxy_ftp.c Sat Aug 9 23:15:27 1997
> @@ -55,6 +55,7 @@
> #include "mod_proxy.h"
> #include "http_main.h"
> #include "mod_mime.h"
> +#include "http_log.h"
>
> /*
> * Decodes a '%' escaped string, and returns the number of characters
> @@ -115,9 +116,19 @@
>
> 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;
> + if (err) {
> + log_reason (err, r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> + if (user != NULL && !ftp_check_string(user)) {
> + log_reason ("invalid user string in ftp proxy request", r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> + if (password != NULL && !ftp_check_string(password)) {
> + log_reason ("invalid password string in ftp proxy request",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
>
> /* now parse path/parameters args, according to rfc1738 */
> /* N.B. if this isn't a true proxy request, then the URL path
> @@ -130,26 +141,44 @@
> {
> *(p++) = '\0';
> parms = proxy_canonenc(pool, p, strlen(p), enc_parm, r->proxyreq);
> - if (parms == NULL) return BAD_REQUEST;
> + if (parms == NULL) {
> + log_reason ("invalid parameters in ftp proxy request",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> } else
> parms = "";
>
> 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 (path == NULL) {
> + log_reason ("bad path in ftp proxy URL", r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> + if (!ftp_check_string(path)) {
> + log_reason ("invalid characters in ftp proxy path", r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
>
> if (!r->proxyreq && r->args != NULL)
> {
> if (p != NULL)
> {
> p = proxy_canonenc(pool, r->args, strlen(r->args), enc_parm, 1);
> - if (p == NULL) return BAD_REQUEST;
> + if (p == NULL) {
> + log_reason ("bad string in ftp proxy (looking for parameters)",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> parms = pstrcat(pool, parms, "?", p, NULL);
> }
> else
> {
> p = proxy_canonenc(pool, r->args, strlen(r->args), enc_fpath, 1);
> - if (p == NULL) return BAD_REQUEST;
> + if (p == NULL) {
> + log_reason ("bad string in ftp proxy (looking for a path)",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> path = pstrcat(pool, path, "?", p, NULL);
> }
> r->args = NULL;
> --- proxy_http.c.orig Sat Aug 9 18:20:58 1997
> +++ proxy_http.c Sat Aug 9 23:15:38 1997
> @@ -75,7 +75,10 @@
> */
> port = def_port;
> err = proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
> - if (err) return BAD_REQUEST;
> + if (err) {
> + log_reason (err, r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
>
> /* now parse path/search args, according to rfc1738 */
> /* N.B. if this isn't a true proxy request, then the URL _path_
> @@ -90,13 +93,20 @@
>
> /* process path */
> path = proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
> - if (path == NULL) return BAD_REQUEST;
> + if (path == NULL) {
> + log_reason ("null/invalid path in http proxy", r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
>
> /* process search */
> if (p != NULL)
> {
> search = p;
> - if (search == NULL) return BAD_REQUEST;
> + if (search == NULL) {
> + log_reason ("null/invalid string in process search, in http proxy",
> + r->filename, r);
> + return HTTP_BAD_REQUEST;
> + }
> } else
> search = NULL;
>
>
>