-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
bound the trailing hex read in my_mb_wc_filename #5187
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
Open
jmestwa-coder
wants to merge
1
commit into
MariaDB:main
Choose a base branch
from
jmestwa-coder:filename-mbwc-overread
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+23
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1704,13 +1704,30 @@ test_strnncollsp_char() | |
| } | ||
|
|
||
|
|
||
| /* | ||
| my_mb_wc_filename() decodes a 5-byte '@HHHH' escape but only checked that | ||
| 4 bytes were available before reading the 4th hex digit at s[4], one byte | ||
| past the supplied end pointer. "@000" is such a truncated escape ('0','0' | ||
| has no entry in the 3-byte table, so it reaches the hex branch). Passing | ||
| end= buf + 4 must not consume the byte at buf[4]. | ||
| */ | ||
| static int test_mb_wc_filename_truncated() | ||
| { | ||
| CHARSET_INFO *cs= &my_charset_filename; | ||
| uchar buf[5]= {'@', '0', '0', '0', '1'}; | ||
| my_wc_t wc= 0; | ||
| int rc= my_ci_mb_wc(cs, &wc, buf, buf + 4); | ||
| return rc != MY_CS_ILSEQ; | ||
| } | ||
|
|
||
|
|
||
| int main(int ac, char **av) | ||
| { | ||
| size_t i, failed= 0; | ||
|
|
||
| MY_INIT(av[0]); | ||
|
|
||
| plan(4); | ||
| plan(5); | ||
| diag("Testing my_like_range_xxx() functions"); | ||
|
|
||
| for (i= 0; i < array_elements(charset_list); i++) | ||
|
|
@@ -1736,6 +1753,10 @@ int main(int ac, char **av) | |
| failed= test_strnncollsp_char(); | ||
| ok(failed == 0, "Testing cs->coll->strnncollsp_char()"); | ||
|
|
||
| diag("Testing my_charset_filename mb_wc end-pointer bounds"); | ||
| ok(test_mb_wc_filename_truncated() == 0, | ||
| "filename decoder does not read past the end pointer"); | ||
|
Comment on lines
+1757
to
+1758
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| my_end(0); | ||
|
|
||
| return exit_status(); | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning the actual return value of
my_ci_mb_wcrather than a boolean mapping makes the test more direct and easier to understand. We can then assert the expected error code (MY_CS_ILSEQ) directly in the test runner.