trifectatechfoundation / sudo-rs

A memory safe implementation of sudo and su.
Other
2.9k stars 79 forks source link

refactor: use `NonNull` to deal with `pam_getenvlist` #758

Closed japaric closed 1 year ago

japaric commented 1 year ago

I had trouble reading the original version and thought that the curr_str passed into CStr::from_ptr was not checked for null-ness but that was done in while condition -- the not very visible dereferencing operator there through me off.

The new version should hopefully make it clearer that a NonNull pointer is being passed into CStr::from_ptr. (Of course, it'd be even better if CStr::from_ptr signature was fn(NonNull<u8>) but we can't change the libstd API.) It also makes the dereferencing more explicit using the read method.

codecov[bot] commented 1 year ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@6d40763). Click here to learn what that means. Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #758 +/- ## ======================================= Coverage ? 55.04% ======================================= Files ? 71 Lines ? 9765 Branches ? 0 ======================================= Hits ? 5375 Misses ? 4390 Partials ? 0 ``` | [Files Changed](https://app.codecov.io/gh/memorysafety/sudo-rs/pull/758?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=memorysafety) | Coverage Δ | | |---|---|---| | [src/pam/mod.rs](https://app.codecov.io/gh/memorysafety/sudo-rs/pull/758?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=memorysafety#diff-c3JjL3BhbS9tb2QucnM=) | `0.00% <0.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 1 year ago

Number of dependencies and binary size impact report

Metric main PR #758 Delta
Direct dependencies 3 3 -
Total dependencies 4 4 -
Binary size 1023.2 KiB 1023.5 KiB -
Text size 594.9 KiB 594.9 KiB -
Dependencies diff ```diff └─ sudo-rs [v0.2.0] ├─ glob [v0.3.1] ├─ libc [v0.2.147] └─ log [v0.4.20] ```