Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix test_subprocess
  • Loading branch information
youknowone committed Dec 12, 2025
commit b9fa405fd4b9ef7e408b3a47c8301d9dda88e88c
1 change: 0 additions & 1 deletion Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ def test_one_environment_variable(self):
self.assertEqual(p.returncode, 0)
self.assertEqual(stdout.strip(), b"fruit=orange")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON, null byte is not checked")
def test_invalid_cmd(self):
# null character in the command name
cmd = sys.executable + '\0'
Expand Down
12 changes: 12 additions & 0 deletions crates/vm/src/stdlib/winapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ mod _winapi {
Ok(ws.into_vec_with_nul())
};

// Validate no embedded null bytes in command name and command line
if let Some(ref name) = args.name
&& name.as_str().contains('\0')
{
return Err(crate::exceptions::cstring_error(vm));
}
if let Some(ref cmd) = args.command_line
&& cmd.as_str().contains('\0')
{
return Err(crate::exceptions::cstring_error(vm));
}

let app_name = args.name.map(wstr).transpose()?;
let app_name = app_name.as_ref().map_or_else(null, |w| w.as_ptr());

Expand Down