Merge pull request #9 from shadow-utils-rs/fix/1-7-critical-bugs

passwd: fix 7 critical bugs (#1-#7)
This commit is contained in:
Pierre Warnier
2026-03-23 13:43:23 +01:00
committed by GitHub
4 changed files with 232 additions and 95 deletions
+3
View File
@@ -38,6 +38,9 @@ thiserror = "2"
nix = { version = "0.29", features = ["user", "fs", "process", "signal", "term"] }
libc = "0.2"
# Security
zeroize = "1"
# Testing
proptest = "1"
tempfile = "3"
+1
View File
@@ -14,6 +14,7 @@ path = "src/lib.rs"
libc = { workspace = true }
nix = { workspace = true }
thiserror = { workspace = true }
zeroize = { workspace = true }
[dev-dependencies]
proptest = { workspace = true }
+9 -1
View File
@@ -28,6 +28,8 @@ use std::io::{self, BufRead, Write};
use std::os::unix::io::AsRawFd;
use std::ptr;
use zeroize::Zeroize;
use crate::error::ShadowError;
// ---------------------------------------------------------------------------
@@ -351,7 +353,13 @@ fn prompt_for_input(
};
match input {
Ok(line) => alloc_c_response(&line),
Ok(mut line) => {
let result = alloc_c_response(&line);
// Zeroize the Rust string so password data does not linger in
// process memory after being copied to the C-allocated response.
line.zeroize();
result
}
Err(_) => Err(()),
}
}
File diff suppressed because it is too large Load Diff