-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix spurious failures of php-fuzz-mbstring #12819
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
Conversation
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.
One theoretical issue I can think of is that you're now relying on the UTF-8 string handling to be correct, so we might miss some bugs?
Also: what if errors3 == 0
(i.e. the input is valid) but errors1>0
and good == true
? I don't think that should be allowed right?
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.
@nielsdos The point of this extra if
clause is that the situation you have described is very possible. It happens if the input string, when interpreted in FromEncoding
, contains codepoints which cannot be represented in ToEncoding
. That causes spurious crashes of the fuzzer.
I wouldn't say we are "relying on UTF-8 string handling to be correct". The point of this code is that if errors1 > 0
, and those errors occurred in the decoder for FromEncoding
, then we will still detect the same errors here and we will get errors3 > 0
.
We are relying on the UTF-8 encoder not to spuriously give errors3 > 0
. But if that happens, it wouldn't result in bugs being missed; rather, it would result in spurious crashes of the fuzzer.
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.
Sorry, you're right indeed; should've commented when I was less tired from the work day ;)
In that case, this patch looks good to me.
@nielsdos Thanks so much for the review. Landed on master.
@Girgias @nielsdos @youkidearitai @cmb69