Welcome! Log In Create A New Profile

Advanced

Re: Lua Variable access bug?

agentzh
May 17, 2012 04:36AM
On Wed, May 16, 2012 at 10:16 AM, Sirsiwal, Umesh <usirsiwal@verivue.com> wrote:
>
> I think issue exists because of the way ngx_http_variables_init_vars is
> written. It changes the flags in the static ngx_http_core_variables variable.
> During the first configuration read cycle where $http_host is indexed, the
> flag changes to indexed. During the second configuration read cycle where
> the the $http_host variable should not be indexed, the flags still remain
> INDEXED. That confuses ngx_http_get_variable later.
>

This is indeed an issue in the nginx core and it should affect other
modules other than ngx_lua.

I think the ngx_http_variables_add_core_vars function should pass a
copy of the ngx_http_variable_t entries in the static variable
ngx_http_core_variables.

Could you please try the patch below for nginx 1.0.15? I've confirmed
that it can also be applied cleanly to nginx 1.2.0.

Thanks!
-agentzh

--- nginx-1.0.15/src/http/ngx_http_variables.c 2012-03-05
20:36:51.000000000 +0800
+++ nginx-1.0.15-patched/src/http/ngx_http_variables.c 2012-05-17
16:21:42.120968722 +0800
@@ -1898,6 +1898,7 @@
{
ngx_int_t rc;
ngx_http_variable_t *v;
+ ngx_http_variable_t *value;
ngx_http_core_main_conf_t *cmcf;

cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
@@ -1918,7 +1919,14 @@
}

for (v = ngx_http_core_variables; v->name.len; v++) {
- rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v,
+ value = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t));
+ if (value == NULL) {
+ return NGX_ERROR;
+ }
+
+ *value = *v;
+
+ rc = ngx_hash_add_key(cmcf->variables_keys, &value->name, value,
NGX_HASH_READONLY_KEY);

if (rc == NGX_OK) {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Lua Variable access bug?

Sirsiwal, Umesh 1683 May 15, 2012 10:18PM

Re: Lua Variable access bug? Attachments

agentzh 509 May 17, 2012 04:36AM

Re: Lua Variable access bug?

Maxim Dounin 497 May 17, 2012 05:04AM

Re: Lua Variable access bug?

agentzh 478 May 17, 2012 07:44AM

Re: Lua Variable access bug?

Maxim Dounin 466 May 17, 2012 09:08AM

Re: Lua Variable access bug?

agentzh 530 May 17, 2012 09:16AM

Re: Lua Variable access bug?

Sirsiwal, Umesh 488 May 17, 2012 09:38AM

Re: Lua Variable access bug?

Maxim Dounin 526 May 17, 2012 02:12PM

Re: Lua Variable access bug?

lanshun zhou 482 May 17, 2012 11:00PM

Re: Lua Variable access bug?

Maxim Dounin 593 May 18, 2012 07:10AM

Re: Lua Variable access bug? Attachments

lanshun zhou 604 May 22, 2012 06:34AM



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

Online Users

Guests: 258
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