Repository navigation
MINOR: [C++][Compute] Reject non-UTF-8 padding in utf8 pad kernels - #54376
Closed
Nayana-Naik73 wants to merge 1 commit into
Closed
Nayana-Naik73 wants to merge 1 commit into
Nayana-Naik73 wants to merge 1 commit into
Conversation
|
Thanks for opening a pull request! This pull request has been automatically closed because you currently have 4 open pull requests, which is more than the limit of 3. Due to the increase in pull requests opened by AI bots, and in order to keep the review queue manageable, Apache Arrow limits contributors without repository access to at most 3 concurrently open pull requests. This helps make sure each pull request gets the attention it needs and that work in progress does not go stale. Once one of your other open pull requests has been merged or closed, you are welcome to reopen this one. See also: |
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.
Rationale for this change
utf8_lpad/utf8_rpad/utf8_centerandutf8_zero_fillcheck that the padding is one codepoint withutil::UTF8Length, which only counts non-continuation bytes and assumes valid UTF-8. A padding like"a"followed by any number of0x80bytes passes that check, butMaxCodeunitssizes the output asinput_ncodeunits + 4 * ninputs * width(at most 4 bytes per codepoint) whileTransformcopies the whole padding string per pad. Withpadding = "a" + std::string(15, '\x80')andwidth = 100, ASan reports a heap-buffer-overflow write inUtf8PadTransform::Transform.What changes are included in this PR?
The padding is required to be valid UTF-8 in both
PreExecchecks, so a padding that passes is at most 4 bytes.util::InitializeUTF8()is called first, as the cast kernels do, sinceValidateUTF8needs the lookup tables.Are these changes tested?
Yes. Added a malformed padding case to
PadUTF8andUTF8ZeroFillinscalar_string_test.cc. Before the fix it overflows under ASan; with the fixarrow-compute-scalar-type-testpasses (ASan Debug build).Are there any user-facing changes?
Padding that is not valid UTF-8 is now rejected with the existing "Padding must be one codepoint" error instead of being accepted.
This PR contains a "Critical Fix". A malformed padding option caused an out-of-bounds write into the output data buffer of these kernels.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
This fix was found and prepared with AI assistance and reviewed by me before submitting.
PR code and description written by:
Reviewed before submission by: