[PATCH 2 of 3] Geo: fixed ngx_file_info() error handling
Maxim Dounin
mdounin at mdounin.ru
Wed Nov 19 14:10:39 UTC 2025
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1763517200 -10800
# Wed Nov 19 04:53:20 2025 +0300
# Node ID 38d3d6ce245e081a4551dbad95e04d3a78ffca39
# Parent a7a3126061282c50ed79c86f9ca72ddd72a10310
Geo: fixed ngx_file_info() error handling.
When ngx_file_info() on the text include file failed when loading a binary
include, the code failed to restore binary file name in "name". While
it is generally not needed after an error, an additional error might
theoretically happen when closing the binary include, and wrong "name"
will result in incorrect file name in the error message.
The fix is to restore "name", much like it is done in the normal code path.
Prodded by Coverity (CID 1306890, 1643342).
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -1464,6 +1464,7 @@ ngx_http_geo_include_binary_base(ngx_con
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);
+ name->data[name->len - 4] = ch;
goto failed;
}
diff --git a/src/stream/ngx_stream_geo_module.c b/src/stream/ngx_stream_geo_module.c
--- a/src/stream/ngx_stream_geo_module.c
+++ b/src/stream/ngx_stream_geo_module.c
@@ -1390,6 +1390,7 @@ ngx_stream_geo_include_binary_base(ngx_c
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);
+ name->data[name->len - 4] = ch;
goto failed;
}
More information about the nginx-devel
mailing list