diff options
author | Igor Sysoev <igor@sysoev.ru> | 2010-06-30 10:02:05 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2010-06-30 10:02:05 +0000 |
commit | 4655c721e86dd33d4e81f14b0930fc6774285524 (patch) | |
tree | 86865a4733ca3447c703a2950c97144e79c5005a | |
parent | edf29ef8cd5827dd292b414489199997d558a6ae (diff) | |
download | nginx-4655c721e86dd33d4e81f14b0930fc6774285524.tar.gz nginx-4655c721e86dd33d4e81f14b0930fc6774285524.zip |
test binary gep range base mtime
-rw-r--r-- | src/http/modules/ngx_http_geo_module.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c index bcb783979..5883a087c 100644 --- a/src/http/modules/ngx_http_geo_module.c +++ b/src/http/modules/ngx_http_geo_module.c @@ -1138,7 +1138,8 @@ static ngx_int_t ngx_http_geo_include_binary_base(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx, ngx_str_t *name) { - u_char *base; + u_char *base, ch; + time_t mtime; size_t size, len; ssize_t n; uint32_t crc32; @@ -1180,6 +1181,24 @@ ngx_http_geo_include_binary_base(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx, } size = (size_t) ngx_file_size(&fi); + mtime = ngx_file_mtime(&fi); + + ch = name->data[name->len - 4]; + name->data[name->len - 4] = '\0'; + + if (ngx_file_info(name->data, &fi) == NGX_FILE_ERROR) { + ngx_conf_log_error(NGX_LOG_CRIT, cf, ngx_errno, + ngx_file_info_n " \"%s\" failed", name->data); + goto failed; + } + + name->data[name->len - 4] = ch; + + if (mtime < ngx_file_mtime(&fi)) { + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "stale binary geo range base \"%s\"", name->data); + goto failed; + } base = ngx_palloc(ctx->pool, size); if (base == NULL) { |