Repository navigation
Conversation
…ve size Follow-up to phpGH-25731, which rejected a negative size in FFI::string(). FFI::memcpy(), FFI::memcmp() and FFI::memset() have the same issue: the size was only compared with the size of non-pointer CData and the length of strings, where a negative size became a huge unsigned one and failed with a misleading data or string boundary error. For pointers, it was passed on to memcpy(), memcmp() or memset() as nearly SIZE_MAX, which crashed. Reject a negative size with a ValueError, like FFI::string() does. As phpGH-25731 is not released yet, its NEWS entry now covers these functions too, and string_negative_size.phpt becomes part of mem_size.phpt, which tests the sizes of all four functions.
Contributor
Author
LamentXU123
approved these changes
Nov 27, 2026
ndossche
approved these changes
Nov 27, 2026
Member
|
I have some concerns on the target branch tho. Although the previous PR get merged, I still think this is quite a behavioral break in stable branches. As far as I can tell, we've done a bunch of fixes to reject NUL bytes by throwing ValueError in functions that have NUL truncation bugs. what is the reason do you think this fix is special enough to go to stable? |
Contributor
Author
I see this as a bug fix. No more reasoning behind. I personally would be fine with master as well. |
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.
Follow-up to GH-25731, which rejected a negative size in FFI::string(). FFI::memcpy(), FFI::memcmp() and FFI::memset() have the same issue: the size was only compared with the size of non-pointer CData and the length of strings, where a negative size became a huge unsigned one and failed with a misleading data or string boundary error. For pointers, it was passed on to memcpy(), memcmp() or memset() as nearly SIZE_MAX, which crashed.
Reject a negative size with a ValueError, like FFI::string() does.
As GH-25731 is not released yet, its NEWS entry now covers these functions too, and string_negative_size.phpt becomes part of mem_size.phpt, which tests the sizes of all four functions.