# HG changeset patch # User Maxim Dounin # Date 1360594705 0 # Node ID 63bc961253eb4b72d4a72a6d469cb318d5bbc61c # Parent ac3690ee6c282416ffd1ca3ed611fcd96bd16434 Merge of r4999, r5003: detect duplicate "events" and "keepalive". *) Upstream keepalive: detect duplicate "keepalive" directive. A failure to detect duplicate "keepalive" directive resulted in stack exhaustion. *) Events: added check for duplicate "events" directive. diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -892,6 +892,10 @@ ngx_events_block(ngx_conf_t *cf, ngx_com ngx_conf_t pcf; ngx_event_module_t *m; + if (*(void **) conf) { + return "is duplicate"; + } + /* count the number of the event modules and set up their indices */ ngx_event_max_module = 0; diff --git a/src/http/modules/ngx_http_upstream_keepalive_module.c b/src/http/modules/ngx_http_upstream_keepalive_module.c --- a/src/http/modules/ngx_http_upstream_keepalive_module.c +++ b/src/http/modules/ngx_http_upstream_keepalive_module.c @@ -502,6 +502,10 @@ ngx_http_upstream_keepalive(ngx_conf_t * kcf = ngx_http_conf_upstream_srv_conf(uscf, ngx_http_upstream_keepalive_module); + if (kcf->original_init_upstream) { + return "is duplicate"; + } + kcf->original_init_upstream = uscf->peer.init_upstream ? uscf->peer.init_upstream : ngx_http_upstream_init_round_robin;