httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: strange behaviour using mod_proxy when the r->filename partially overlaps the requested uri
Date Tue, 21 Aug 2012 11:55:34 GMT
On 2012-08-21 13:39, nik600 wrote:
>
> static int kcache_handler_translate(request_rec* r)
> {
>      if (r->method_number != M_GET && r->method_number != M_POST){
>          return HTTP_METHOD_NOT_ALLOWED;
>      }
>
> 	if(
> 		strstr(r->unparsed_uri, "/files/anteprima")==NULL){
> 		return DECLINED;
> 	}  	
>    	
>    	char *newurl = "proxy:http://www.foooo.com/nocachedfiles/anteprima/12345";	
>
>    	r->filename = apr_pcalloc(r->pool,strlen(newurl));

Replace with

apr_pcalloc(r->pool, strlen(newurl) + 1);

in order to allocate space for the closing '\0'.

> 	strcpy(r->filename,newurl);
>      r->proxyreq = PROXYREQ_PROXY;
>      r->handler  = "proxy-server";
>
>      return DECLINED;
>
> }
>
> static void register_hooks(apr_pool_t* pool)
> {
>
>
> 	static const char *succ[] =
> {"mod_proxy.c","mod_alias.c","mod_userdir.c", NULL};
>      ap_hook_translate_name(kcache_handler_translate, NULL, succ,
> APR_HOOK_MIDDLE);
> }
>
> /***********************************************/
>
>


Mime
View raw message