-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #61700: FILTER_FLAG_IPV6/FILTER_FLAG_NO_PRIV|RES_RANGE failing #7476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
It makes no sense to compare IPv6 address ranges as strings; there are too many different representation possibilities. Instead, we change `_php_filter_validate_ipv6()` so that it can calculate the IP address as integer array. We do not rely on `inet_pton()` which may not be available everywhere, at least IPv6 support may not, but rather parse the IP address manually. Finally, we compare the integers. Note that this patch does not fix what we consider as reserved and private, respectively, but merely tries to keep what we had so far.
In my opinion, fixing this bug is important, but I'm not sure about the details, so I'd like some review. |
nikic
reviewed
Sep 20, 2021
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
We also need to do this for `blocks == 8`, to replace the single `-1` with `0`. In this case the first `for` loop is unnecessary, but it doesn't really hurt to run it.
nikic
reviewed
Sep 20, 2021
nikic
approved these changes
Sep 20, 2021
cmb69
pushed a commit
that referenced
this pull request
Dec 19, 2021
`2001:10::/28` is a reserved IPv6 range. But there's a typo in GH-7476, which caused IPv6 address like `240b:0010::1` will be filtered by the flag `FILTER_FLAG_NO_RES_RANGE`. http://www.faqs.org/rfcs/rfc6890.html Closes GH-7790.
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.
It makes no sense to compare IPv6 address ranges as strings; there are
too many different representation possibilities. Instead, we change
_php_filter_validate_ipv6()
so that it can calculate the IP addressas integer array. We do not rely on
inet_pton()
which may not beavailable everywhere, at least IPv6 support may not, but rather parse
the IP address manually. Finally, we compare the integers.
Note that this patch does not fix what we consider as reserved and
private, respectively, but merely tries to keep what we had so far.
Regarding
filter_var('::ffff:192.168.1.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)
: it is not necessarily clear what this should return. In the bug ticket, requinix argues that it likely should fail, but it currently does not.