Skip to content

Commit

Permalink
Merge pull request #59 from defanator/defanator-fix-auto_reload
Browse files Browse the repository at this point in the history
Ensure that database structures are zero-initialized
  • Loading branch information
leev authored Oct 2, 2018
2 parents d6e529a + 38cea8a commit cbea8fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions ngx_http_geoip2_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions ngx_stream_geoip2_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit cbea8fc

Please sign in to comment.