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

Remove all unnecessary unsafe from bzip2.rs #48

Merged
merged 17 commits into from
Nov 21, 2024
Merged

Conversation

bjorn3
Copy link
Collaborator

@bjorn3 bjorn3 commented Nov 20, 2024

This removes the SIGSEGV handler, uses a helper thread for cleaning up after ctrl-c (currently untested on Windows) and removes all mutable statics and introduces a safe abstraction around *mut FILE.

All remaining unsafe code in bzip2.rs is either to call into libbzip2 or to interface with the OS.

We shouldn't segfault and if we do anyway, we probably should abort as
soon as possible rather than trying to access a bunch of possibly
corrupted state to maybe give a nicer crash message and in the process
possibly open up a security hole.
This will enable it to call functions that are not async-signal safe.
This will make it possible to clone a Config in the future and pass it
to the ctrl-c cleanup thread.
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 79.29760% with 112 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bzip2.rs 79.29% 112 Missing ⚠️
Files with missing lines Coverage Δ
bzip2.rs 83.48% <79.29%> (+1.33%) ⬆️

🚨 Try these New Features:

This enables marking almost all functions in bzip2.rs as safe.
@bjorn3 bjorn3 changed the title Make a fair amount of functions in bzip2.rs safe Remove all unnecessary unsafe from bzip2.rs Nov 20, 2024
tests/quick.rs Show resolved Hide resolved
bzip2.rs Outdated Show resolved Hide resolved
bzip2.rs Show resolved Hide resolved
bzip2.rs Outdated Show resolved Hide resolved
bzip2.rs Outdated Show resolved Hide resolved
bzip2.rs Show resolved Hide resolved
This reverts commit 2babbc6.

Also fix the test that made me think I had to use perror.
@folkertdev folkertdev merged commit 94f2414 into main Nov 21, 2024
13 of 14 checks passed
@folkertdev folkertdev deleted the less_unsafe_functions branch November 21, 2024 14:49
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