You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2016/10/03 00:36:11 UTC

[trafficserver] branch master updated: Fix possibility of NULL assignment to std::string

This is an automated email from the ASF dual-hosted git repository.

sorber pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  91bfe21   Fix possibility of NULL assignment to std::string
91bfe21 is described below

commit 91bfe214cc2356ae19b78776815d0344d1a0906d
Author: Phil Sorber <so...@apache.org>
AuthorDate: Sun Oct 2 18:18:35 2016 -0600

    Fix possibility of NULL assignment to std::string
---
 plugins/header_rewrite/expander.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plugins/header_rewrite/expander.cc b/plugins/header_rewrite/expander.cc
index 22dca9c..c62a7d0 100644
--- a/plugins/header_rewrite/expander.cc
+++ b/plugins/header_rewrite/expander.cc
@@ -67,7 +67,12 @@ VariableExpander::expand(const Resources &res)
       // Protocol of the incoming request
       if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
         int len;
-        resolved_variable = TSUrlSchemeGet(bufp, url_loc, &len);
+        const char *tmp = TSUrlSchemeGet(bufp, url_loc, &len);
+        if ((tmp != NULL) && (len > 0)) {
+          resolved_variable.assign(tmp, len);
+        } else {
+          resolved_variable.assign("");
+        }
         TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
       }
     } else if (variable == "%<port>") {

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].

Re: [trafficserver] branch master updated: Fix possibility of NULL assignment to std::string

Posted by James Peach <jp...@apache.org>.
> On Oct 2, 2016, at 5:36 PM, sorber@apache.org wrote:
> 
> This is an automated email from the ASF dual-hosted git repository.
> 
> sorber pushed a commit to branch master
> in repository https://git-dual.apache.org/repos/asf/trafficserver.git
> 
> The following commit(s) were added to refs/heads/master by this push:
>       new  91bfe21   Fix possibility of NULL assignment to std::string
> 91bfe21 is described below
> 
> commit 91bfe214cc2356ae19b78776815d0344d1a0906d
> Author: Phil Sorber <so...@apache.org>
> AuthorDate: Sun Oct 2 18:18:35 2016 -0600
> 
>    Fix possibility of NULL assignment to std::string
> ---
> plugins/header_rewrite/expander.cc | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/header_rewrite/expander.cc b/plugins/header_rewrite/expander.cc
> index 22dca9c..c62a7d0 100644
> --- a/plugins/header_rewrite/expander.cc
> +++ b/plugins/header_rewrite/expander.cc
> @@ -67,7 +67,12 @@ VariableExpander::expand(const Resources &res)
>       // Protocol of the incoming request
>       if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
>         int len;
> -        resolved_variable = TSUrlSchemeGet(bufp, url_loc, &len);
> +        const char *tmp = TSUrlSchemeGet(bufp, url_loc, &len);
> +        if ((tmp != NULL) && (len > 0)) {
> +          resolved_variable.assign(tmp, len);
> +        } else {
> +          resolved_variable.assign("");
> +        }

FWIW every other place in this file does

if (tmp && len) {
	resolved_variable.assign(tmp, len);
}


Re: [trafficserver] branch master updated: Fix possibility of NULL assignment to std::string

Posted by James Peach <jp...@apache.org>.
> On Oct 2, 2016, at 5:36 PM, sorber@apache.org wrote:
> 
> This is an automated email from the ASF dual-hosted git repository.
> 
> sorber pushed a commit to branch master
> in repository https://git-dual.apache.org/repos/asf/trafficserver.git
> 
> The following commit(s) were added to refs/heads/master by this push:
>       new  91bfe21   Fix possibility of NULL assignment to std::string
> 91bfe21 is described below
> 
> commit 91bfe214cc2356ae19b78776815d0344d1a0906d
> Author: Phil Sorber <so...@apache.org>
> AuthorDate: Sun Oct 2 18:18:35 2016 -0600
> 
>    Fix possibility of NULL assignment to std::string
> ---
> plugins/header_rewrite/expander.cc | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/header_rewrite/expander.cc b/plugins/header_rewrite/expander.cc
> index 22dca9c..c62a7d0 100644
> --- a/plugins/header_rewrite/expander.cc
> +++ b/plugins/header_rewrite/expander.cc
> @@ -67,7 +67,12 @@ VariableExpander::expand(const Resources &res)
>       // Protocol of the incoming request
>       if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
>         int len;
> -        resolved_variable = TSUrlSchemeGet(bufp, url_loc, &len);
> +        const char *tmp = TSUrlSchemeGet(bufp, url_loc, &len);
> +        if ((tmp != NULL) && (len > 0)) {
> +          resolved_variable.assign(tmp, len);
> +        } else {
> +          resolved_variable.assign("");
> +        }

FWIW every other place in this file does

if (tmp && len) {
	resolved_variable.assign(tmp, len);
}