Skip to content
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

[SR-3343] Investigate Array Canaries for withUnsafe operations #45931

Open
swift-ci opened this issue Dec 6, 2016 · 0 comments
Open

[SR-3343] Investigate Array Canaries for withUnsafe operations #45931

swift-ci opened this issue Dec 6, 2016 · 0 comments
Labels
diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 6, 2016

Previous ID SR-3343
Radar rdar://problem/16553648
Original Reporter Gankro (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement, DiagnosticsQoI, StarterBug
Assignee abdullah (JIRA)
Priority Medium

md5: c68651c162da6db48a6cc867e161ffe0

Issue Description:

We provide several operations which expose the guts of an Array as an UnsafePointer in a closure. This provides an opportunity for developers to mess up and scribble past the bounds of the Array. As a QoI feature, we should look into opportunistically installing a canary at the end of the Array in debug builds.

Basic idea:

  • At the start of withUnsafeBufferPointer (before the closure is called), check if the array has some slack capacity.

  • If it does, write some specific bit pattern to the extra space (just the last byte?).

  • At the end of withUnsafeBufferPointer (after the closure has been called), check if the bit pattern is in tact. If not, assert that a buffer overflow occurred.

This obviously isn't a robust protection against buffer overflows, but maybe it will catch some programmer errors!

I'm happy to mentor anyone who wishes to work on this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant