]> git.kaiwu.me - nginx.git/commitdiff
GeoIP: not all variable fields were initialized.
authorYichun Zhang <agentzh@gmail.com>
Fri, 25 Jul 2014 21:43:29 +0000 (14:43 -0700)
committerYichun Zhang <agentzh@gmail.com>
Fri, 25 Jul 2014 21:43:29 +0000 (14:43 -0700)
The ngx_http_geoip_city_float_variable and
ngx_http_geoip_city_int_variable functions did not always initialize
all variable fields like "not_found", which could lead to empty values
for those corresponding nginx variables randomly.

src/http/modules/ngx_http_geoip_module.c

index 1af166e62954c4a9a5696a5449b35b7d8209a400..8e151aa8f20cc67741c36b36ecc18787867aaf38 100644 (file)
@@ -553,6 +553,9 @@ ngx_http_geoip_city_float_variable(ngx_http_request_t *r,
     val = *(float *) ((char *) gr + data);
 
     v->len = ngx_sprintf(v->data, "%.4f", val) - v->data;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
 
     GeoIPRecord_delete(gr);
 
@@ -582,6 +585,9 @@ ngx_http_geoip_city_int_variable(ngx_http_request_t *r,
     val = *(int *) ((char *) gr + data);
 
     v->len = ngx_sprintf(v->data, "%d", val) - v->data;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
 
     GeoIPRecord_delete(gr);