Skip to content

[5.3] Fix NULL deref for invalid mangled input (#31878) #31979

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

tbkka
Copy link
Contributor

@tbkka tbkka commented May 22, 2020

This is a nomination to merge this change into release/5.3

Original description: The Qo operator expects to consume a type name and a list (terminated with a y empty list marker) from the stack. After popping the list, it doesn't check whether the stack is empty, so $syQo crashes (it pops down to the y then tries to pop again).

This PR just adds the obvious check to guard against this.

Risk: Minor. We just fail if a nullptr is encountered at one point where valid input should never give us a nullptr. The code would previously segfault at this point. This should only ever happen on malformed input.

Testing: Verified by original reporter, CI testing, local validation test runs.

Resolves rdar://63128307

The `Qo` operator expects to consume a type name and a list (terminated with a `y` empty list marker) from the stack.  After popping the list, it doesn't check whether the stack is empty, so `$syQo` crashes (it pops down to the `y` then tries to pop again).

This PR just adds the obvious check to guard against this.

Resolves rdar://63128307
@tbkka tbkka requested a review from a team as a code owner May 22, 2020 21:52
@tbkka
Copy link
Contributor Author

tbkka commented May 22, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 934df1d

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 934df1d

@tbkka
Copy link
Contributor Author

tbkka commented May 23, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 934df1d

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 934df1d

@airspeedswift airspeedswift merged commit d26abce into swiftlang:release/5.3 Jul 2, 2020
@tbkka tbkka deleted the tbkka-rdar63128307-demangler-dmangleArchetype-5.3 branch October 16, 2020 00:32
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants