Skip to content

Commit b9fa405

Browse files
committed
Fix test_subprocess
1 parent 5a5b721 commit b9fa405

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Lib/test/test_subprocess.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ def test_one_environment_variable(self):
857857
self.assertEqual(p.returncode, 0)
858858
self.assertEqual(stdout.strip(), b"fruit=orange")
859859

860-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON, null byte is not checked")
861860
def test_invalid_cmd(self):
862861
# null character in the command name
863862
cmd = sys.executable + '\0'

crates/vm/src/stdlib/winapi.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,18 @@ mod _winapi {
248248
Ok(ws.into_vec_with_nul())
249249
};
250250

251+
// Validate no embedded null bytes in command name and command line
252+
if let Some(ref name) = args.name
253+
&& name.as_str().contains('\0')
254+
{
255+
return Err(crate::exceptions::cstring_error(vm));
256+
}
257+
if let Some(ref cmd) = args.command_line
258+
&& cmd.as_str().contains('\0')
259+
{
260+
return Err(crate::exceptions::cstring_error(vm));
261+
}
262+
251263
let app_name = args.name.map(wstr).transpose()?;
252264
let app_name = app_name.as_ref().map_or_else(null, |w| w.as_ptr());
253265

0 commit comments

Comments
 (0)