diff src/http/ngx_http_variables.c @ 4972:8b635cf36ccc

Added checks that disallow adding a variable with an empty name. Added variable name syntax checks to "geo" and "map" directives.
author Ruslan Ermilov <ru@nginx.com>
date Mon, 17 Dec 2012 19:03:33 +0000
parents ec7d97006a30
children 829cc5872186
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -330,6 +330,12 @@ ngx_http_add_variable(ngx_conf_t *cf, ng
     ngx_http_variable_t        *v;
     ngx_http_core_main_conf_t  *cmcf;
 
+    if (name->len == 0) {
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           "invalid variable name \"$\"");
+        return NULL;
+    }
+
     cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
 
     key = cmcf->variables_keys->keys.elts;
@@ -393,6 +399,12 @@ ngx_http_get_variable_index(ngx_conf_t *
     ngx_http_variable_t        *v;
     ngx_http_core_main_conf_t  *cmcf;
 
+    if (name->len == 0) {
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           "invalid variable name \"$\"");
+        return NGX_ERROR;
+    }
+
     cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
 
     v = cmcf->variables.elts;