Repository navigation
Fix mbregex fuzzer not being built and truncating its input - #24720
Open
yumasansansan wants to merge 1 commit into
Open
yumasansansan wants to merge 1 commit into
yumasansansan wants to merge 1 commit into
Conversation
The mbregex fuzzer was only built if --enable-mbregex was passed explicitly. SAPIs are configured before extensions, so only enable_mbregex is available here, and it is unset unless the option is given, although mbregex is enabled by default together with mbstring. The fuzzer also passed its input through strlen(), dropping everything after the first NUL byte, although mb_ereg() accepts NUL bytes in both the pattern and the subject.
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.
Two problems in the mbregex fuzzer:
sapi/fuzzer/config.m4buildsphp-fuzz-mbregexonly iftest -n "$enable_mbregex". Becausesapi/*/config.m4is evaluated beforeext/*/config.m4,PHP_MBREGEXis not known yet, andenable_mbregexis only set if--enable-mbregex/--disable-mbregexis given on the command line. With./configure --enable-fuzzer --enable-mbstring(as documented in the README), mbregex is compiled in (HAVE_MBREGEXis defined), butphp-fuzz-mbregexis not built.fuzzer_call_php_func()creates the arguments withZVAL_STRING(), i.e.strlen(), so the pattern and subject end at the first NUL byte, and the part of the input space containing NUL bytes was never passed to Oniguruma. The fuzzer now passes the input with its length. For the inputa\0b,onig_new()now receives a 3 byte pattern.The input format is unchanged, existing corpora stay valid.