mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Merge pull request #3980 from Yaminyam/fix/module-pwd
Fix: check if name contains null byte
This commit is contained in:
1 file changed
+4
@@ -5,6 +5,7 @@ mod pwd {
|
||||
use crate::{
|
||||
builtins::{PyIntRef, PyStrRef},
|
||||
convert::{IntoPyException, ToPyObject},
|
||||
exceptions,
|
||||
types::PyStructSequence,
|
||||
AsObject, PyObjectRef, PyResult, VirtualMachine,
|
||||
};
|
||||
@@ -52,6 +53,9 @@ mod pwd {
|
||||
|
||||
#[pyfunction]
|
||||
fn getpwnam(name: PyStrRef, vm: &VirtualMachine) -> PyResult<Passwd> {
|
||||
if name.as_str().contains('\0') {
|
||||
return Err(exceptions::cstring_error(vm));
|
||||
}
|
||||
match User::from_name(name.as_str()).map_err(|err| err.into_pyexception(vm))? {
|
||||
Some(user) => Ok(Passwd::from(user)),
|
||||
None => {
|
||||
|
||||
Reference in new issue
Block a user