Welcome! Log In Create A New Profile

Advanced

[nginx] Gzip: fixed style in $gzip_ratio variable handler.

June 15, 2017 06:06AM
details: http://hg.nginx.org/nginx/rev/ab5117642647
branches:
changeset: 7033:ab5117642647
user: Ruslan Ermilov <ru@nginx.com>
date: Wed Jun 14 12:49:20 2017 +0300
description:
Gzip: fixed style in $gzip_ratio variable handler.

The current style in variable handlers returning NGX_OK is to either set
v->not_found to 1, or to initialize the entire ngx_http_variable_value_t
structure.

In theory, always setting v->valid = 1 for NGX_OK would be useful, which
would mean that the value was computed and is thus valid, including the
special case of v->not_found = 1. But currently that's not the case and
causes the (v->valid || v->not_found) check to access an uninitialized
v->valid value, which is safe only because its value doesn't matter when
v->not_found is set.

diffstat:

src/http/modules/ngx_http_gzip_filter_module.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diffs (25 lines):

diff -r d48c8cdac201 -r ab5117642647 src/http/modules/ngx_http_gzip_filter_module.c
--- a/src/http/modules/ngx_http_gzip_filter_module.c Wed Jun 14 12:29:52 2017 +0300
+++ b/src/http/modules/ngx_http_gzip_filter_module.c Wed Jun 14 12:49:20 2017 +0300
@@ -1084,10 +1084,6 @@ ngx_http_gzip_ratio_variable(ngx_http_re
ngx_uint_t zint, zfrac;
ngx_http_gzip_ctx_t *ctx;

- v->valid = 1;
- v->no_cacheable = 0;
- v->not_found = 0;
-
ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);

if (ctx == NULL || ctx->zout == 0) {
@@ -1095,6 +1091,10 @@ ngx_http_gzip_ratio_variable(ngx_http_re
return NGX_OK;
}

+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+
v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3);
if (v->data == NULL) {
return NGX_ERROR;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Gzip: fixed style in $gzip_ratio variable handler.

ru@nginx.com 874 June 15, 2017 06:06AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready