mirror of
https://github.com/uutils/shadow.git
synced 2026-06-10 16:14:57 -07:00
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:
@@ -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"
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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(()),
|
||||
}
|
||||
}
|
||||
|
||||
+219
-94
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user