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

ByteBuffer: deal correctly with underreporting ContiguousCollections #501

Merged
merged 2 commits into from Jul 12, 2018

Conversation

weissi
Copy link
Member

@weissi weissi commented Jul 4, 2018

Motivation:

ContiguousCollections shouldn't give access to more than count bytes
via withUnsafeBytes but if they do we should still handle this
correctly and only copy count bytes.

Modifications:

  • copy an upper limit of count bytes
  • fail hard if withUnsafeBytes offers fewer bytes as we can't do
    anything sensible then.

Result:

even illegal ContiguousCollection implementations don't cause issues.

@weissi weissi force-pushed the jw-underreporting-cc branch 2 times, most recently from 02d0efa to 073ff4e Compare July 4, 2018 21:02
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Lukasa
Copy link
Contributor

Lukasa commented Jul 5, 2018

@swift-nio-bot test this please

@Lukasa Lukasa added the patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Jul 5, 2018
@Lukasa Lukasa added this to the 1.9.0 milestone Jul 5, 2018
Motivation:

ContiguousCollections shouldn't give access to more than `count` bytes
via `withUnsafeBytes` but if they do we should still handle this
correctly and only copy `count` bytes.

Modifications:

- copy an upper limit of `count` bytes
- fail hard if `withUnsafeBytes` offers fewer bytes as we can't do
  anything sensible then.

Result:

even illegal `ContiguousCollection` implementations don't cause issues.
@weissi weissi merged commit 072babe into apple:master Jul 12, 2018
@weissi weissi deleted the jw-underreporting-cc branch July 12, 2018 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants