From 0961aacb08b9255d7cea520dd46f175523a3e40e Mon Sep 17 00:00:00 2001 From: bneradt Date: Wed, 24 Jun 2026 17:46:33 -0500 Subject: [PATCH] Trace skipped X-Remap injection Add debug breadcrumbs when xdebug skips X-Remap injection because snprintf fails or returns an empty value, and when the generated value is truncated to the fixed buffer. This makes the secured formatting path easier to diagnose without changing header behavior. --- plugins/xdebug/xdebug.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/xdebug/xdebug.cc b/plugins/xdebug/xdebug.cc index 32cd8631372..71a9389e586 100644 --- a/plugins/xdebug/xdebug.cc +++ b/plugins/xdebug/xdebug.cc @@ -402,8 +402,11 @@ InjectRemapHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr) TSfree(const_cast(toUrlStr)); } - if (len > 0) { + if (len <= 0) { + Dbg(dbg_ctl, "skipping X-Remap header injection because snprintf returned %d", len); + } else { if (static_cast(len) >= sizeof(buf)) { + Dbg(dbg_ctl, "truncating X-Remap header from %d to %zu bytes", len, sizeof(buf) - 1); len = sizeof(buf) - 1; } TSReleaseAssert(TSMimeHdrFieldValueStringInsert(buffer, hdr, dst, -1 /* idx */, buf, len) == TS_SUCCESS);