Fix crash when bogus string input is provided to hl_date_from_string#929
Draft
sebbernery wants to merge 1 commit into
Draft
Fix crash when bogus string input is provided to hl_date_from_string#929sebbernery wants to merge 1 commit into
sebbernery wants to merge 1 commit into
Conversation
…or format digest function. Added a new function in hl.h, hl_to_utf8_len, same as hl_to_utf8 but with a len parameter Updated hl_utf16_to_utf8 to replace '!= end' by '< end' because c can be incremented two times in the loop and it may be an issue with invalid input.
Author
|
I just noted that my fix is incorrect as it can raise a segfault when there was no problem before with the date parsing, I think it comes from this : https://github.com/HaxeFoundation/haxe/blob/development/std/hl/_std/Date.hx#L157 . The length of the string given is multiplied by two, so I think it's not coherent with the real size of the buffer. I don't get why. I switched the PR in draft mode. |
Collaborator
|
Note also: on Windows, the try-catch catched the access violation, and it won't access violation if I trace input before |
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.
Fix crash when bogus string input is provided to hl_date_from_string or format digest function.
Added a new function in hl.h, hl_to_utf8_len, same as hl_to_utf8 but with a len parameter Updated hl_utf16_to_utf8 to replace '!= end' by '< end' because c can be incremented two times in the loop and it may be an issue with invalid input.
Here is a reproductible example :
segfault_fixed_by_utf8_len.txt
Here is the reproductible example for Shadigest (with the same input):
I found this issue with AFL++ by trying fuzzing on some Haxe std function. Don't hesitate to ask if you need more details (I kept some notes during the debugging process, but it's in french).
I didn't used any LLM in the entire process from writting Haxe script or fixes or this PR.
Have a nice day !