mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
merge r3283, r3284:
fix segfault if $limit_rate was logged fix segfault in SSL if limit_rate is used
This commit is contained in:
parent
94558617d1
commit
30a57a1262
@ -986,7 +986,7 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
|
|
||||||
while (in && buf->last < buf->end) {
|
while (in && buf->last < buf->end && send < limit) {
|
||||||
if (in->buf->last_buf || in->buf->flush) {
|
if (in->buf->last_buf || in->buf->flush) {
|
||||||
flush = 1;
|
flush = 1;
|
||||||
}
|
}
|
||||||
@ -1013,8 +1013,8 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
ngx_memcpy(buf->last, in->buf->pos, size);
|
ngx_memcpy(buf->last, in->buf->pos, size);
|
||||||
|
|
||||||
buf->last += size;
|
buf->last += size;
|
||||||
|
|
||||||
in->buf->pos += size;
|
in->buf->pos += size;
|
||||||
|
send += size;
|
||||||
|
|
||||||
if (in->buf->pos == in->buf->last) {
|
if (in->buf->pos == in->buf->last) {
|
||||||
in = in->next;
|
in = in->next;
|
||||||
@ -1039,7 +1039,6 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf->pos += n;
|
buf->pos += n;
|
||||||
send += n;
|
|
||||||
c->sent += n;
|
c->sent += n;
|
||||||
|
|
||||||
if (n < size) {
|
if (n < size) {
|
||||||
|
@ -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);
|
ngx_http_variable_value_t *v, uintptr_t data);
|
||||||
static void ngx_http_variable_request_set(ngx_http_request_t *r,
|
static void ngx_http_variable_request_set(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data);
|
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,
|
static void ngx_http_variable_request_set_size(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data);
|
ngx_http_variable_value_t *v, uintptr_t data);
|
||||||
static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r,
|
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 },
|
offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 },
|
||||||
|
|
||||||
{ ngx_string("limit_rate"), ngx_http_variable_request_set_size,
|
{ 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),
|
offsetof(ngx_http_request_t, limit_rate),
|
||||||
NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
|
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
|
static void
|
||||||
ngx_http_variable_request_set_size(ngx_http_request_t *r,
|
ngx_http_variable_request_set_size(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data)
|
ngx_http_variable_value_t *v, uintptr_t data)
|
||||||
|
Loading…
Reference in New Issue
Block a user