You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by James Peach <jp...@apache.org> on 2013/11/05 22:42:46 UTC

Re: git commit: TS-2320: TSRedirectUrlSet truncates host header in redirected request Updated to memcpy based on James Peach's recomendation Also, saw a problem with malloc and sizeof when switching the code to only use alloca. Using a variable length array

On Nov 5, 2013, at 1:37 PM, bcall@apache.org wrote:

> Updated Branches:
>  refs/heads/master ab996456f -> 5ad8eabdf
> 
> 
> TS-2320: TSRedirectUrlSet truncates host header in redirected request
> Updated to memcpy based on James Peach's recomendation
> Also, saw a problem with malloc and sizeof when switching the code to only
> use alloca.  Using a variable length array all the time now.

Nice!

> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5ad8eabd
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5ad8eabd
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5ad8eabd
> 
> Branch: refs/heads/master
> Commit: 5ad8eabdf87d465e13791c8451591cf0d986e760
> Parents: ab99645
> Author: Bryan Call <bc...@apache.org>
> Authored: Tue Nov 5 13:35:08 2013 -0800
> Committer: Bryan Call <bc...@apache.org>
> Committed: Tue Nov 5 13:35:08 2013 -0800
> 
> ----------------------------------------------------------------------
> proxy/http/HttpSM.cc | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5ad8eabd/proxy/http/HttpSM.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
> index 06f6096..e5751a0 100644
> --- a/proxy/http/HttpSM.cc
> +++ b/proxy/http/HttpSM.cc
> @@ -7393,17 +7393,11 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
> 
>     if (host != NULL) {
>       int port = clientUrl.port_get();
> -#if defined(__GNUC__)
>       char buf[host_len + 7];
> -#else
> -      char *buf = (char *)ats_malloc(host_len + 7);
> -#endif
> -      ink_strlcpy(buf, host, host_len+1);
> +
> +      memcpy(buf, host, host_len);
>       host_len += snprintf(buf + host_len, sizeof(buf) - host_len, ":%d", port);
>       t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, buf, host_len);
> -#if !defined(__GNUC__)
> -      ats_free(buf);
> -#endif
>     } else {
>       // the client request didn't have a host, so remove it from the headers
>       t_state.hdr_info.client_request.field_delete(MIME_FIELD_HOST, MIME_LEN_HOST);
>