[nginx] Xslt: proper logging of long errors.

Maxim Dounin mdounin at mdounin.ru
Fri Mar 6 04:23:33 UTC 2026


details:   http://freenginx.org/hg/nginx/rev/d7e6f90ec255
branches:  
changeset: 9472:d7e6f90ec255
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri Mar 06 07:11:37 2026 +0300
description:
Xslt: proper logging of long errors.

To ensure that long error messages from the libxml2 library can be
properly logged by ngx_http_xslt_sax_error(), the buffer size was
changed to NGX_MAX_CONF_ERRSTR.  It is smaller than NGX_MAX_ERROR_STR,
the size of the low-level buffer used during logging, and therefore
reserves some space for other information.  Similar approach is used
in ngx_conf_log_error(), where the macro comes from, as well as various
other places, such as ngx_ssl_error().

diffstat:

 src/http/modules/ngx_http_xslt_filter_module.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (32 lines):

diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c
--- a/src/http/modules/ngx_http_xslt_filter_module.c
+++ b/src/http/modules/ngx_http_xslt_filter_module.c
@@ -544,7 +544,7 @@ ngx_http_xslt_sax_error(void *data, cons
     va_list                      args;
     ngx_uint_t                   truncated;
     ngx_http_xslt_filter_ctx_t  *ctx;
-    u_char                       buf[NGX_MAX_ERROR_STR];
+    u_char                       buf[NGX_MAX_CONF_ERRSTR];
 
     ctx = ctxt->sax->_private;
 
@@ -552,7 +552,7 @@ ngx_http_xslt_sax_error(void *data, cons
     truncated = 0;
 
     va_start(args, msg);
-    n = vsnprintf((char *) buf, NGX_MAX_ERROR_STR, msg, args);
+    n = vsnprintf((char *) buf, NGX_MAX_CONF_ERRSTR, msg, args);
     va_end(args);
 
     if (n < 0) {
@@ -560,8 +560,8 @@ ngx_http_xslt_sax_error(void *data, cons
         truncated = 1;
     }
 
-    if (n >= NGX_MAX_ERROR_STR) {
-        n = NGX_MAX_ERROR_STR - 1;
+    if (n >= NGX_MAX_CONF_ERRSTR) {
+        n = NGX_MAX_CONF_ERRSTR - 1;
         truncated = 1;
     }
 


More information about the nginx-devel mailing list