mirror of
https://github.com/apache/httpd.git
synced 2026-10-23 22:49:01 +03:00
NUL-terminated string in place, returning a pointer to the new terminating NUL. * include/httpd.h: Declare ap_cstr_stripws(). * server/util.c (ap_cstr_stripws): Implement it, handling the empty-string case safely. (ap_getline): Use it; adjust the returned length and memmove size accordingly. * modules/http/byterange_filter.c, modules/mappers/mod_negotiation.c, modules/metadata/mod_cern_meta.c, modules/proxy/mod_proxy_hcheck.c, modules/proxy/mod_proxy_http.c, modules/proxy/mod_proxy_uwsgi.c, server/util_script.c: Replace open-coded trailing-whitespace stripping loops with ap_cstr_stripws(). This avoids the undefined behaviour of forming &value[strlen(value)-1], which points before the start of the string when the value is empty. * modules/metadata/mod_cern_meta.c, server/util_script.c: Use apr_pstrmemdup() with the returned end pointer rather than apr_pstrdup(). * include/ap_mmn.h: Bump MMN minor. * test/unit/util.c: Add ap_cstr_stripws() unit tests. * test/modules/proxy/test_03_response.py, test/modules/proxy/test_05_uwsgi.py: Add tests for empty backend response header values. Submitted by: Robert McConnell <robert mcc0nnell.org>, jorton GitHub: closes #749 Assisted-By: Claude Opus 4.8 <noreply@anthropic.com> git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1938194 13f79535-47bb-0310-9956-ffa450edef68