Repository navigation
[2.4.x] Merge ap_size_parameter_parse() - #1116
Merged
Merged
Conversation
core: Reject invalid values of LimitXMLRequestBody. set_limit_xml_req_body() used atol(), so "abc123" and "123abc" were accepted as 0 and 123, and a value out of range of a long gave an undefined result. Parse the whole argument with apr_strtoff() like LimitRequestBody, and reject values that do not fit in limit_xml_body or exceed AP_MAX_LIMIT_XML_BODY. PR: 69975 GitHub: closes apache#825 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939121 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit c1b7c82)
…Vquota change omitted, not in 2.4.x; test changes already on 2.4.x): core: Add common apr_off_t config parser Add ap_size_parameter_parse(), a helper to parse a configuration value as an apr_off_t, which fails on trailing characters and on overflow. The range of the value remains up to the directive. Use it for configuration directives which parsed such values in different ways, some of them accepting trailing characters or doing no checks at all: LimitRequestBody (unchanged behavior), ScriptLogLength, ScriptLogBuffer, DavQuota, BufferSize, AuthFormSize, and the mod_cache_disk and mod_cache_socache size and time directives. GitHub: closes apache#829 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939129 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit ba3fa29)
core: Distinguish invalid size parameters from range errors ap_size_parameter_parse() returned APR_ERANGE for a value without any digits where the libc sets EINVAL when nothing is converted (FreeBSD, musl), and APR_EINVAL with glibc. end == parameter tells portably that nothing was converted, so check it before the apr_strtoff() status. APR_EINVAL is for invalid syntax, APR_ERANGE stays for overflow and underflow. Use it for LimitXMLRequestBody too, which had its own apr_strtoff() parsing from apache#825, so that it reports the same errors as LimitRequestBody on every platform. No change in the accepted values. Extend test_012 to check that LimitRequestBody reports invalid syntax and range errors with their own messages, and to cover LimitXMLRequestBody. GitHub: closes apache#848 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939163 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit 93d7164)
core: Accept a b/k/m/g suffix in size-valued directive parameters: * server/util.c (ap_size_parameter_parse): Allow an optional case-insensitive 'b', 'k', 'm' or 'g' suffix, bounding the multiplication by the range of apr_off_t. * include/httpd.h: Update doxygen accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> GitHub: PR apache#851 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939295 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit 973155c)
modules/filters/mod_substitute.c (set_max_line_length): Use ap_size_parameter_parse(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> GitHub: closes apache#851 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939296 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit aa1e6c0)
(TestLimitXMLRequestBody.test_core_010_002, TestLimitXMLRequestBody.test_core_010_003), test/modules/core/test_012_config_off_t.py (OFF_T, OFF_T_WIN), test/modules/filters/test_004_buffer_size.py (STRICT): Mark as backported in 2.4.72. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
notroj
force-pushed
the
2.4.x-size-parameter-parse
branch
from
November 28, 2026 15:46
7cd8031 to
de16b77
Compare
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Member
|
Compared each commit with its trunk revision: identical apart from the MMN (.145 is right on top of #1097/#1111), the omitted DAVquota hunk and the changes entry. Builds clean here, also against APR 1.5.2 with the APR_ERANGE fallback (fails without it, as expected). The tests with backported_in="2.4.72" fail on unpatched 2.4.x and pass with the PR (366 passed). One thing worth a line in CHANGES and the docs, on trunk too: the suffix is user-visible. LimitRequestBody now accepts b/k/m/g, and "CacheMaxFileSize 10k" used to be read as 10 bytes and is now 10240; "10MB" and similar now fail at startup instead of being truncated. |
arturobernalg
approved these changes
Nov 28, 2026
Collaborator
Author
|
Thanks @arturobernalg - will merge this as-is then amend docs/CHANGES separately. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge r1939121, r1939129, r1939163, r1939295, r1939296 from trunk:
r1939129 had a conflict in
include/ap_mmn.h, resolved as a minor bump to 20120211.145. Itsmod_dav_fs.cchange is omitted becauseDAVquotais not in 2.4.x, andDavQuotais dropped from the changes entry to match. The test changes of all these revisions were already on 2.4.x.APR_ERANGEonly exists from APR 1.6, soinclude/httpd.hgains a fallback definition (ERANGE) for the APR 1.4 that 2.4.x still supports.A further commit adds
backported_in="2.4.72"to thenot_backportedmarks for r1939121, r1939129 and r1939163; the same commit needs to land on trunk.🤖 Generated with Claude Code