-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Demangler] Accept overly short type names if they are NUL terminated #77346
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.
Yuck. Manglings can contain embedded NUL
characters in some circumstances, so this is pretty horrible. I don't see an alternative, though, and it's allowing NUL
only when we're expecting an operator so maybe that's OK.
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.
Looks like a reasonable compromise
swift_getTypeByMangledNameInContext takes a pointer and a length, but some programs pass a pointer to a NUL-terminated C string and an excessive length, implicitly relying on the terminator to end the string early. This worked previously, but commit 7fe2bef made the demangler more strict about bad data. This changes the demangler to successfully parse a name by terminating the name string at a 0 byte encountered where it expects to find an operator. All other cases of bad data continue to be rejected. rdar://137430048
65153ad
to
4a5dc2a
Compare
Yes, this still properly handles the expected embedded NULs, we just accept names where a NUL occurs where we expect an operator, rather than rejecting them. I've also added a test case so we can ensure this keeps working. |
@swift-ci please test |
@swift-ci please test |
Hit the failure fixed by #77366 |
@swift-ci please smoke test |
swift_getTypeByMangledNameInContext takes a pointer and a length, but some programs pass a pointer to a NUL-terminated C string and an excessive length, implicitly relying on the terminator to end the string early. This worked previously, but commit 7fe2bef made the demangler more strict about bad data. This changes the demangler to successfully parse a name by terminating the name string at a 0 byte encountered where it expects to find an operator. All other cases of bad data continue to be rejected.
rdar://137430048