[PATCH 2 of 2] Xslt: proper logging of long errors

Maxim Dounin mdounin at mdounin.ru
Thu Feb 26 01:17:43 UTC 2026


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1772068488 -10800
#      Thu Feb 26 04:14:48 2026 +0300
# Node ID 9f204b12e0b421f0255f2e92e31d4b56a0657c2d
# Parent  525677dd6b0a766fc61796ce4d74b5619132d33e
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().

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