You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Lars Eilebrecht <La...@unix-ag.org> on 1997/08/16 03:46:01 UTC
[PATCH] for 1.3/1.2.x: more mod_proxy stuff - PR#260,656,699,713,812
Hi,
below you find a patch for proxy_http.c. The patch is against 1.3, but
should work with 1.2.3 too.
Altough the fix is trivial it fixes PR#260, 656, 699, 713 and 812.
The first four PRs are related: The request to a remote proxy
was mangled if it was generated as the result of a ProxyPass
directive.
PR#812: URL schemes other than http:// are not supported when
ProxyRemote is used, because of some code from times where mod_proxy
was only able to deal with http://. The bug resulted in a mangled
request to the remote proxy.
-snip-
*** src/modules/proxy/proxy_http.c Sat Jul 19 10:58:15 1997
--- /usr/home/sfx/apache_1.3a1/src/modules/proxy/proxy_http.c Sat Aug 16 02:11:46 1997
***************
*** 156,161 ****
--- 156,162 ----
const long int zero=0L;
int destport = 0;
char *destportstr = NULL;
+ char *urlptr = NULL;
void *sconf = r->server->module_config;
proxy_server_conf *conf =
***************
*** 169,187 ****
/* We break the URL into host, port, path-search */
! url += 7; /* skip http:// */
destport = DEFAULT_PORT;
! p = strchr(url, '/');
if (p == NULL)
{
! desthost = pstrdup(pool, url);
! url = "/";
} else
{
! char *q = palloc(pool, p-url+1);
! memcpy(q, url, p-url);
! q[p-url] = '\0';
! url = p;
desthost = q;
}
--- 170,189 ----
/* We break the URL into host, port, path-search */
! urlptr = strstr(url,"://");
! urlptr += 3;
destport = DEFAULT_PORT;
! p = strchr(urlptr, '/');
if (p == NULL)
{
! desthost = pstrdup(pool, urlptr);
! urlptr = "/";
} else
{
! char *q = palloc(pool, p-urlptr+1);
! memcpy(q, urlptr, p-urlptr);
! q[p-urlptr] = '\0';
! urlptr = p;
desthost = q;
}
***************
*** 207,213 ****
if (proxyhost != NULL)
{
! url = r->uri; /* restore original URL */
server.sin_port = htons(proxyport);
err = proxy_host2addr(proxyhost, &server_hp);
if (err != NULL) return DECLINED; /* try another */
--- 209,215 ----
if (proxyhost != NULL)
{
! urlptr = r->uri; /* restore original URL */
server.sin_port = htons(proxyport);
err = proxy_host2addr(proxyhost, &server_hp);
if (err != NULL) return DECLINED; /* try another */
-snap-
ciao...
--
Lars Eilebrecht
sfx@unix-ag.org
Re: [PATCH] for 1.3/1.2.x: more mod_proxy stuff - PR#260,656,699,713,812
Posted by Dean Gaudet <dg...@arctic.org>.
On Sat, 16 Aug 1997, Lars Eilebrecht wrote:
> Altough the fix is trivial it fixes PR#260, 656, 699, 713 and 812.
>
> *** src/modules/proxy/proxy_http.c Sat Jul 19 10:58:15 1997
> --- /usr/home/sfx/apache_1.3a1/src/modules/proxy/proxy_http.c Sat Aug 16 02:11:46 1997
> ***************
> *** 156,161 ****
> --- 156,162 ----
> const long int zero=0L;
> int destport = 0;
> char *destportstr = NULL;
> + char *urlptr = NULL;
>
> void *sconf = r->server->module_config;
> proxy_server_conf *conf =
> ***************
> *** 169,187 ****
>
> /* We break the URL into host, port, path-search */
>
> ! url += 7; /* skip http:// */
> destport = DEFAULT_PORT;
> ! p = strchr(url, '/');
> if (p == NULL)
> {
> ! desthost = pstrdup(pool, url);
> ! url = "/";
> } else
> {
> ! char *q = palloc(pool, p-url+1);
> ! memcpy(q, url, p-url);
> ! q[p-url] = '\0';
> ! url = p;
> desthost = q;
> }
>
> --- 170,189 ----
>
> /* We break the URL into host, port, path-search */
>
> ! urlptr = strstr(url,"://");
> ! urlptr += 3;
This core dumps if the url doesn't contain :// ... is that guaranteed to
be there?
> destport = DEFAULT_PORT;
> ! p = strchr(urlptr, '/');
> if (p == NULL)
> {
> ! desthost = pstrdup(pool, urlptr);
> ! urlptr = "/";
> } else
> {
> ! char *q = palloc(pool, p-urlptr+1);
> ! memcpy(q, urlptr, p-urlptr);
> ! q[p-urlptr] = '\0';
> ! urlptr = p;
> desthost = q;
> }
>
> ***************
> *** 207,213 ****
>
> if (proxyhost != NULL)
> {
> ! url = r->uri; /* restore original URL */
> server.sin_port = htons(proxyport);
> err = proxy_host2addr(proxyhost, &server_hp);
> if (err != NULL) return DECLINED; /* try another */
> --- 209,215 ----
>
> if (proxyhost != NULL)
> {
> ! urlptr = r->uri; /* restore original URL */
> server.sin_port = htons(proxyport);
> err = proxy_host2addr(proxyhost, &server_hp);
> if (err != NULL) return DECLINED; /* try another */
>
> -snap-
urlptr isn't used at all any further down in the function, so there's no
need to assign to it here.
Dean