Skip to content

Commit cbea8fc

Browse files
authored
Merge pull request #59 from defanator/defanator-fix-auto_reload
Ensure that database structures are zero-initialized
2 parents d6e529a + 38cea8a commit cbea8fc

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

ngx_http_geoip2_module.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ ngx_http_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
426426
return NGX_CONF_ERROR;
427427
}
428428

429+
ngx_memzero(database, sizeof(ngx_http_geoip2_db_t));
430+
429431
database->last_check = database->last_change = ngx_time();
430432

431433
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)
437439
return NGX_CONF_ERROR;
438440
}
439441

440-
#if (NGX_HAVE_INET6)
441-
ngx_memset(&database->address, 0, sizeof(database->address));
442-
#else
443-
database->address = 0;
444-
#endif
445-
446442
save = *cf;
447443
cf->handler = ngx_http_geoip2_parse_config;
448444
cf->handler_conf = (void *) database;

ngx_stream_geoip2_module.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ ngx_stream_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
395395
return NGX_CONF_ERROR;
396396
}
397397

398+
ngx_memzero(database, sizeof(ngx_stream_geoip2_db_t));
399+
398400
database->last_check = database->last_change = ngx_time();
399401

400402
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)
406408
return NGX_CONF_ERROR;
407409
}
408410

409-
#if (NGX_HAVE_INET6)
410-
ngx_memset(&database->address, 0, sizeof(database->address));
411-
#else
412-
database->address = 0;
413-
#endif
414-
415411
save = *cf;
416412
cf->handler = ngx_stream_geoip2_parse_config;
417413
cf->handler_conf = (void *) database;

0 commit comments

Comments
 (0)