trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Peach <jpe...@apache.org>
Subject Re: trafficserver git commit: TS-3224: fix problem of ts_lua coredump
Date Wed, 10 Dec 2014 16:17:11 GMT

> On Dec 10, 2014, at 6:18 AM, kichan@apache.org wrote:
> 
> Repository: trafficserver
> Updated Branches:
>  refs/heads/master 156b7be9c -> 60c97c6f0
> 
> 
> TS-3224: fix problem of ts_lua coredump
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/60c97c6f
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/60c97c6f
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/60c97c6f
> 
> Branch: refs/heads/master
> Commit: 60c97c6f04538a1cd176f412dfc2622b9008936e
> Parents: 156b7be
> Author: Kit Chan <kichan@apache.org>
> Authored: Wed Dec 10 06:17:50 2014 -0800
> Committer: Kit Chan <kichan@apache.org>
> Committed: Wed Dec 10 06:17:50 2014 -0800
> 
> ----------------------------------------------------------------------
> CHANGES                                              |  2 ++
> plugins/experimental/ts_lua/ts_lua_cached_response.c |  8 ++++++--
> plugins/experimental/ts_lua/ts_lua_client_request.c  | 14 +++++++++++---
> plugins/experimental/ts_lua/ts_lua_client_response.c |  8 ++++++--
> plugins/experimental/ts_lua/ts_lua_server_request.c  |  6 +++++-
> plugins/experimental/ts_lua/ts_lua_server_response.c |  9 +++++++--
> 6 files changed, 37 insertions(+), 10 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/60c97c6f/CHANGES
> ----------------------------------------------------------------------
> diff --git a/CHANGES b/CHANGES
> index c091270..51f119e 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -1,6 +1,8 @@
>                                                          -*- coding: utf-8 -*-
> Changes with Apache Traffic Server 5.3.0
> 
> +  *) [TS-3224] fix ts_lua core dump issue.
> +
>   *) [TS-3229] Filter unsupported epic metric names.
> 
>   *) [TS-3230] Remove unused ink_error APIs.
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/60c97c6f/plugins/experimental/ts_lua/ts_lua_cached_response.c
> ----------------------------------------------------------------------
> diff --git a/plugins/experimental/ts_lua/ts_lua_cached_response.c b/plugins/experimental/ts_lua/ts_lua_cached_response.c
> index abc30b7..74935fb 100644
> --- a/plugins/experimental/ts_lua/ts_lua_cached_response.c
> +++ b/plugins/experimental/ts_lua/ts_lua_cached_response.c
> @@ -131,8 +131,12 @@ ts_lua_cached_response_get_version(lua_State * L)
> 
>   version = TSHttpHdrVersionGet(http_ctx->cached_response_bufp, http_ctx->cached_response_hdrp);
> 
> -  n = snprintf(buf, sizeof(buf) - 1, "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> -  lua_pushlstring(L, buf, n);
> +  n = snprintf(buf, sizeof(buf), "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> +  if(n >= sizeof(buf)) {
> +    lua_pushlstring(L, buf, sizeof(buf) - 1);
> +  } else {
> +    lua_pushlstring(L, buf, n);
> +  }

Maybe a common function, instead of 4 copies of this code?

> 
>   return 1;
> }
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/60c97c6f/plugins/experimental/ts_lua/ts_lua_client_request.c
> ----------------------------------------------------------------------
> diff --git a/plugins/experimental/ts_lua/ts_lua_client_request.c b/plugins/experimental/ts_lua/ts_lua_client_request.c
> index 9d6cd26..14a5353 100644
> --- a/plugins/experimental/ts_lua/ts_lua_client_request.c
> +++ b/plugins/experimental/ts_lua/ts_lua_client_request.c
> @@ -499,7 +499,11 @@ ts_lua_client_request_get_uri(lua_State * L)
> 
>   uri_len = snprintf(uri, TS_LUA_MAX_URL_LENGTH, "/%.*s", path_len, path);
> 
> -  lua_pushlstring(L, uri, uri_len);
> +  if(uri_len >= TS_LUA_MAX_URL_LENGTH) {
> +    lua_pushlstring(L, uri, TS_LUA_MAX_URL_LENGTH - 1);
> +  } else {
> +    lua_pushlstring(L, uri, uri_len);
> +  }
> 
>   return 1;
> }
> @@ -762,8 +766,12 @@ ts_lua_client_request_get_version(lua_State * L)
> 
>   version = TSHttpHdrVersionGet(http_ctx->client_request_bufp, http_ctx->client_request_hdrp);
> 
> -  n = snprintf(buf, sizeof(buf) - 1, "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> -  lua_pushlstring(L, buf, n);
> +  n = snprintf(buf, sizeof(buf), "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> +  if (n >= sizeof(buf)) {
> +    lua_pushlstring(L, buf, sizeof(buf) - 1);
> +  } else {
> +    lua_pushlstring(L, buf, n);
> +  }
> 
>   return 1;
> }
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/60c97c6f/plugins/experimental/ts_lua/ts_lua_client_response.c
> ----------------------------------------------------------------------
> diff --git a/plugins/experimental/ts_lua/ts_lua_client_response.c b/plugins/experimental/ts_lua/ts_lua_client_response.c
> index ac98869..9c8030d 100644
> --- a/plugins/experimental/ts_lua/ts_lua_client_response.c
> +++ b/plugins/experimental/ts_lua/ts_lua_client_response.c
> @@ -309,8 +309,12 @@ ts_lua_client_response_get_version(lua_State * L)
> 
>   version = TSHttpHdrVersionGet(http_ctx->client_response_bufp, http_ctx->client_response_hdrp);
> 
> -  n = snprintf(buf, sizeof(buf) - 1, "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> -  lua_pushlstring(L, buf, n);
> +  n = snprintf(buf, sizeof(buf), "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> +  if (n >= sizeof(buf)) {
> +    lua_pushlstring(L, buf, sizeof(buf) - 1);
> +  } else {
> +    lua_pushlstring(L, buf, n);
> +  }
> 
>   return 1;
> }
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/60c97c6f/plugins/experimental/ts_lua/ts_lua_server_request.c
> ----------------------------------------------------------------------
> diff --git a/plugins/experimental/ts_lua/ts_lua_server_request.c b/plugins/experimental/ts_lua/ts_lua_server_request.c
> index b0d11ca..9eb6a8e 100644
> --- a/plugins/experimental/ts_lua/ts_lua_server_request.c
> +++ b/plugins/experimental/ts_lua/ts_lua_server_request.c
> @@ -322,7 +322,11 @@ ts_lua_server_request_get_uri(lua_State * L)
> 
>   uri_len = snprintf(uri, TS_LUA_MAX_URL_LENGTH, "/%.*s", path_len, path);
> 
> -  lua_pushlstring(L, uri, uri_len);
> +  if(uri_len >= TS_LUA_MAX_URL_LENGTH) {
> +    lua_pushlstring(L, uri, TS_LUA_MAX_URL_LENGTH - 1);
> +  } else {
> +    lua_pushlstring(L, uri, uri_len);
> +  }
> 
>   return 1;
> }
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/60c97c6f/plugins/experimental/ts_lua/ts_lua_server_response.c
> ----------------------------------------------------------------------
> diff --git a/plugins/experimental/ts_lua/ts_lua_server_response.c b/plugins/experimental/ts_lua/ts_lua_server_response.c
> index 6a0bbd0..465436e 100644
> --- a/plugins/experimental/ts_lua/ts_lua_server_response.c
> +++ b/plugins/experimental/ts_lua/ts_lua_server_response.c
> @@ -290,9 +290,14 @@ ts_lua_server_response_get_version(lua_State * L)
> 
>   version = TSHttpHdrVersionGet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp);
> 
> -  n = snprintf(buf, sizeof(buf) - 1, "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> -  lua_pushlstring(L, buf, n);
> +  n = snprintf(buf, sizeof(buf), "%d.%d", TS_HTTP_MAJOR(version), TS_HTTP_MINOR(version));
> 
> +  if(n >= sizeof(buf)) {
> +    lua_pushlstring(L, buf, sizeof(buf) - 1);
> +  } else {
> +    lua_pushlstring(L, buf, n);
> +  }
> +  
>   return 1;
> }
> 
> 


Mime
View raw message