Repository navigation
core: Distinguish invalid size parameters from range errors - #848
Closed
arturobernalg wants to merge 1 commit into
Closed
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
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.
arturobernalg
force-pushed
the
fix/size-parameter-parse-einval
branch
from
October 15, 2026 08:25
0687364 to
d287ae8
Compare
This was referenced Oct 15, 2026
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.
ap_size_parameter_parse()(#829) returnedAPR_ERANGEfor a value without any digits (abc,+,-) on libc implementations wherestrtoll()setsEINVALwhen nothing is converted, such as FreeBSD and musl. glibc leaveserrnoalone there, so the function returnedAPR_EINVAL, as documented. The result depended on the libc.When nothing is converted the C library stores the start of the string in the end pointer, so
end == parametertells portably that nothing was converted. Check it before theapr_strtoff()status.APR_EINVALis for invalid syntax,APR_ERANGEstays for overflow and underflow.LimitXMLRequestBody (#825) had its own
apr_strtoff()parsing and had the same problem, so use the common function there as well. This is the change of #847. No change in the accepted values.test_core_012_005checks that LimitRequestBody reports invalid syntax and range errors with their own messages, and LimitXMLRequestBody is added to the directives oftest_012. On glibc these tests pass with or without the change; they only catch the problem on FreeBSD and musl.Tested with trunk at ba3fa29:
test/modules/core279 passed; for 15 LimitRequestBody values the result is the same as before.test_010andtest_012: 7 failed and 228 passed on trunk, 235 passed with this change.ap_size_parameter_parse()alone, with 14 inputs (valid, no digits, trailing characters, overflow, underflow): all correct on glibc and on musl (Alpine 3.17). On musl trunk gets 5 of them wrong.No CHANGES entry:
ap_size_parameter_parse()is trunk only and was never released, and the accepted values do not change.(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).(No new log messages.)
changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).(Not needed, see above.)
test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.