Various fixups to unsafe code (#37651)

A collection of fixups of possibly-unsound code and removing some small
useless writes.

Release Notes:

- N/A
This commit is contained in:
Nia
2025-09-06 00:27:14 +02:00
committed by GitHub
parent 64b6e8ba0f
commit 59bdbf5a5d
8 changed files with 183 additions and 173 deletions
+3 -1
View File
@@ -256,6 +256,9 @@ fn load_shell_from_passwd() -> Result<()> {
&mut result,
)
};
anyhow::ensure!(!result.is_null(), "passwd entry for uid {} not found", uid);
// SAFETY: If `getpwuid_r` doesn't error, we have the entry here.
let entry = unsafe { pwd.assume_init() };
anyhow::ensure!(
@@ -264,7 +267,6 @@ fn load_shell_from_passwd() -> Result<()> {
uid,
status
);
anyhow::ensure!(!result.is_null(), "passwd entry for uid {} not found", uid);
anyhow::ensure!(
entry.pw_uid == uid,
"passwd entry has different uid ({}) than getuid ({}) returned",