mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 07:07:33 -04:00
windows: return error if DecomposeCommandLine parameter contains NUL
DecomposeCommandLine is documented to use CommandLineToArgv, and the CommandLineToArgvW system call inherently does not support strings with internal NUL bytes. This CL changes DecomposeCommandLine to reject those strings with an error instead of panicking. Fixes golang/go#58817 Change-Id: I22a026bf2e69344a21f04849c50ba19b6e7b2007 Reviewed-on: https://go-review.googlesource.com/c/sys/+/487695 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
@@ -626,6 +626,22 @@ func TestCommandLineRecomposition(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// check that windows.DecomposeCommandLine returns error for strings with NUL
|
||||
testsWithNUL := []string{
|
||||
"\x00abcd",
|
||||
"ab\x00cd",
|
||||
"abcd\x00",
|
||||
"\x00abcd\x00",
|
||||
"\x00ab\x00cd\x00",
|
||||
"\x00\x00\x00",
|
||||
}
|
||||
for _, test := range testsWithNUL {
|
||||
_, err := windows.DecomposeCommandLine(test)
|
||||
if err == nil {
|
||||
t.Errorf("Failed to return error while decomposing %#q string with NUL inside", test)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWinVerifyTrust(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user