Open
Description
What version of Go are you using (go version
)?
https://pkg.go.dev/golang.org/x/sys@v0.12.0/windows#CommandLineToArgv
What did you do?
Fuzz test windows.DecomposeCommandLine
, which used to use windows.CommandLineToArgv
as follows:
var argc int32
argv, err := CommandLineToArgv(&utf16CommandLine[0], &argc)
if err != nil {
return nil, err
}
defer LocalFree(Handle(unsafe.Pointer(argv)))
var args []string
for _, v := range (*argv)[:argc] {
args = append(args, UTF16ToString((*v)[:]))
}
return args, nil
What did you expect to see?
A return type from CommandLineToArgv
that is consistent with its argc
return value, and matches the signature documented in https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw.
What did you see instead?
Go's CommandLineToArgv
wrapper hard-codes the bounds on the return value at 8192 entries of 8192 characters each:
func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error)
The hard-coded bound is incorrect, and can cause callers to panic when attempting to index into argv
by argc
.
(attn @golang/windows)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming