Merge pull request #3980 from Yaminyam/fix/module-pwd

Fix: check if name contains null byte
This commit is contained in:
Jeong YunWon authored and GitHub committed 2022-07-29 02:26:40 +09:00
commit 0341e72d94
1 file changed
+4
+4
View File
@@ -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 => {