From 38cea8a516a4f21d3845ba1a17f12dfdac3d8dc5 Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Mon, 1 Oct 2018 15:30:11 +0300 Subject: [PATCH] Ensure that database structures are zero-initialized This should fix #58. --- ngx_http_geoip2_module.c | 8 ++------ ngx_stream_geoip2_module.c | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ngx_http_geoip2_module.c b/ngx_http_geoip2_module.c index c28eb00..e3e3cb7 100644 --- a/ngx_http_geoip2_module.c +++ b/ngx_http_geoip2_module.c @@ -426,6 +426,8 @@ ngx_http_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } + ngx_memzero(database, sizeof(ngx_http_geoip2_db_t)); + database->last_check = database->last_change = ngx_time(); status = MMDB_open((char *) value[1].data, MMDB_MODE_MMAP, &database->mmdb); @@ -437,12 +439,6 @@ ngx_http_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } -#if (NGX_HAVE_INET6) - ngx_memset(&database->address, 0, sizeof(database->address)); -#else - database->address = 0; -#endif - save = *cf; cf->handler = ngx_http_geoip2_parse_config; cf->handler_conf = (void *) database; diff --git a/ngx_stream_geoip2_module.c b/ngx_stream_geoip2_module.c index b9d0260..f988e6a 100644 --- a/ngx_stream_geoip2_module.c +++ b/ngx_stream_geoip2_module.c @@ -395,6 +395,8 @@ ngx_stream_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } + ngx_memzero(database, sizeof(ngx_stream_geoip2_db_t)); + database->last_check = database->last_change = ngx_time(); status = MMDB_open((char *) value[1].data, MMDB_MODE_MMAP, &database->mmdb); @@ -406,12 +408,6 @@ ngx_stream_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } -#if (NGX_HAVE_INET6) - ngx_memset(&database->address, 0, sizeof(database->address)); -#else - database->address = 0; -#endif - save = *cf; cf->handler = ngx_stream_geoip2_parse_config; cf->handler_conf = (void *) database;