Custom Module Directive is Duplicate? Error in conf?

Maxim Dounin mdounin at mdounin.ru
Fri Oct 23 15:12:45 UTC 2015


Hello!

On Fri, Oct 23, 2015 at 10:01:34AM -0400, de_nginx_noob wrote:

> After compiling a test module that sets a variable equal to "test
> successful", I get a "directive is duplicate in (path to conf file)"

[...]

> 	conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_netacuity_conf_t));
> 	if(conf == NULL) {
> 		return NULL;
> 	}
> 	conf->featureCode = NGX_CONF_UNSET_UINT;

Note: featureCode is initialized to NGX_CONF_UNSET_UINT, while 
it's defined as ngx_int_t.

The NGX_CONF_UNSET_UINT macro is (ngx_uint_t) -1, that is, it's 
maximum value representable in the ngx_uint_t type.  Assigning it 
to an ngx_int_t variable will result in integer overflow and the 
behaviour is undefined.  Depending on your C compiler and various 
other factors this may or may not work (or may wipe your hard 
disk).

Correct macro to use here is NGX_CONF_UNSET.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list