details:   http://freenginx.org/hg/nginx/rev/93554e06fe71
branches:  
changeset: 9441:93554e06fe71
user:      Maxim Dounin <[email protected]>
date:      Sun Nov 30 06:21:19 2025 +0300
description:
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).

diffstat:

 src/http/modules/ngx_http_geo_module.c |  1 +
 src/stream/ngx_stream_geo_module.c     |  1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diffs (22 lines):

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;
     }
 

Reply via email to