fix: JsonSockLogMaxHeaders counts configured headers by position

The limit now applies to the position in the configured list, not to the
number of headers actually present in the request. This matches the
documented behavior: headers beyond position N are never logged regardless
of their presence.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
toto
2026-03-05 15:29:53 +01:00
parent 98e413be68
commit f018f0e1f6
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
%global spec_version 1.0.17
%global spec_version 1.0.18
Name: mod_reqin_log
Version: %{spec_version}
@ -37,6 +37,10 @@ install -m 644 %{_pkgroot}/%{_sysconfdir}/httpd/conf.d/mod_reqin_log.conf %{buil
%doc %{_docdir}/%{name}
%changelog
* Thu Mar 05 2026 Developer <dev@example.com> - 1.0.18
- FIX: JsonSockLogMaxHeaders now counts configured headers (by position in list)
regardless of their presence in the request, matching the documented behavior
* Thu Mar 05 2026 Developer <dev@example.com> - 1.0.17
- CONFIG: Extend default JsonSockLogHeaders list (User-Agent, Referer, X-Forwarded-For,
Sec-CH-UA*, Sec-Fetch-*, Accept, Accept-Language, Accept-Encoding)

View File

@ -837,6 +837,9 @@ static void log_request(request_rec *r, reqin_log_config_t *cfg, reqin_log_child
continue;
}
/* Count against the limit regardless of header presence in the request */
header_count++;
header_value = get_header(r, header_name);
if (header_value != NULL) {
@ -864,8 +867,6 @@ static void log_request(request_rec *r, reqin_log_config_t *cfg, reqin_log_child
truncated = apr_pstrmemdup(pool, header_value, val_len);
append_json_string(&buf, truncated);
dynbuf_append(&buf, "\"", 1);
header_count++;
}
}
}