Repository navigation
[rcore] Fix GetDirectoryPath() and GetPrevDirectoryPath() buffer overflow on long paths - #6340
Closed
emincan2000 wants to merge 1 commit into
Closed
emincan2000 wants to merge 1 commit into
emincan2000 wants to merge 1 commit into
Conversation
…flow on long paths
Owner
|
@emincan2000 It seems you used same AI than #6331 Please, next time check the open PRs... did you even try raylib? |
Contributor
Author
|
You're right, sorry about that. I ran into it while testing the path functions with long paths under ASan and didn't look through the open PRs first, #6331 already covers it. Closing this one. |
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.
Both copy into a static MAX_FILEPATH_LENGTH buffer without checking the length, so a path of around 4096 chars writes past the end (ASan global-buffer-overflow). On Windows MAX_FILEPATH_LENGTH is only 260, so it's a lot easier to hit there. GetDirectoryPath("") also reads filePath[1], one byte past the string.
The copy is now capped to the buffer size. I put the relative path check in a variable since it was written out three times. Normal paths give the same result as before, I compared 20k random paths against the old build.