From 8fdc4db91561316f0ab036fb4d5629a26ead777c Mon Sep 17 00:00:00 2001 From: siontama Date: Fri, 29 Jul 2022 01:43:15 +0900 Subject: [PATCH] Fix: check name contain null --- vm/src/stdlib/pwd.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vm/src/stdlib/pwd.rs b/vm/src/stdlib/pwd.rs index 88ca11e25..f44b04179 100644 --- a/vm/src/stdlib/pwd.rs +++ b/vm/src/stdlib/pwd.rs @@ -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 { + 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 => {