Skip to content

Audit the use of unsafe in method.rs#410

Merged
seanmonstar merged 3 commits intohyperium:masterfrom
sbosnick:audit_method
May 7, 2020
Merged

Audit the use of unsafe in method.rs#410
seanmonstar merged 3 commits intohyperium:masterfrom
sbosnick:audit_method

Conversation

@sbosnick
Copy link
Contributor

Refactors the supporting types for Method to extract the uses of unsafe into a smaller leaf sub-module (called extension) that encapsulates these two uses of unsafe into a safe abstraction. Documents the invariants of the safe abstraction that ensure that the uses of unsafe are sound.

The tests for invalid methods test invalid byte sequences including
invalid utf-8 and valid utf-8 that uses invalid characters for a Method.
The tests for valid methods test both short and long extension methods.

Also extract all of the unit tests into a "test" module.
Extract the inner types for ExtensionAllocated and ExtensionInline into
a separate extension module that has the supporting functions as
non-public elements.

This refactoring moves the use of "unsafe" into this new "extension"
module and provides a safe wrappers around the two uses of "unsafe".
The internal InlineExtension and AllocatedExtension types have
invariants that ensure that the two uses of "unsafe" in the "extension"
submodule of "method" are safe. This documents those invariants for
future reference.
Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

I really dig the encapsulation into an extension module here, nice work!

@seanmonstar seanmonstar merged commit dc865ff into hyperium:master May 7, 2020
@sbosnick sbosnick deleted the audit_method branch May 9, 2020 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants