summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_variables.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-02-01 15:20:43 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-02-01 15:20:43 +0000
commit30a57a1262b93ef60405285d206388caa6ad8081 (patch)
tree00e706d4d90b37b21de52a840bf204043d55db96 /src/http/ngx_http_variables.c
parent94558617d1815e93b772d45627f7cdc142bf3f1b (diff)
downloadnginx-30a57a1262b93ef60405285d206388caa6ad8081.tar.gz
nginx-30a57a1262b93ef60405285d206388caa6ad8081.tar.bz2
merge r3283, r3284:
fix segfault if $limit_rate was logged fix segfault in SSL if limit_rate is used
Diffstat (limited to '')
-rw-r--r--src/http/ngx_http_variables.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index b25e64889..fc8ca9b02 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -14,6 +14,8 @@ static ngx_int_t ngx_http_variable_request(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static void ngx_http_variable_request_set(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_request_get_size(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static void ngx_http_variable_request_set_size(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r,
@@ -238,7 +240,7 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 },
{ ngx_string("limit_rate"), ngx_http_variable_request_set_size,
- ngx_http_variable_request,
+ ngx_http_variable_request_get_size,
offsetof(ngx_http_request_t, limit_rate),
NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
@@ -568,6 +570,28 @@ ngx_http_variable_request_set(ngx_http_request_t *r,
}
+static ngx_int_t
+ngx_http_variable_request_get_size(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ size_t *sp;
+
+ sp = (size_t *) ((char *) r + data);
+
+ v->data = ngx_pnalloc(r->pool, NGX_SIZE_T_LEN);
+ if (v->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ v->len = ngx_sprintf(v->data, "%uz", *sp) - v->data;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+
+ return NGX_OK;
+}
+
+
static void
ngx_http_variable_request_set_size(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)