-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/windows: EnumProcesses cuts the PIDs buffer size #60223
Comments
Thanks for reporting this issue @roman-mazur.
Do you want to give it a try (see the Contribution Guide)? Else I'll pick it. A good solution would be to redefine //sys EnumProcesses to generate an unexported function that accepts an explicit length, like this:
Then implement the @golang/windows |
I was thinking at first about adjusting the generated code to be |
Implementation generated directly with mkwinsyscall has a wrong assumption about the expected value for PIDs buffer size. This change adds some small manual code that converts the input slice length to the number of bytes of the array backing the slice. A test is also added. It fails with the previous implementation. Fixes golang/go#60223 Change-Id: I5e2414acb29c6c949e5e6acd328043f8a8883887
Implementation generated directly with mkwinsyscall has a wrong assumption about the expected value for PIDs buffer size. This change adds some small manual code that converts the input slice length to the number of bytes of the array backing the slice. A test is also added. It fails with the previous implementation. Fixes golang/go#60223 Change-Id: I5e2414acb29c6c949e5e6acd328043f8a8883887
Change https://go.dev/cl/495995 mentions this issue: |
Implementation generated directly with mkwinsyscall has a wrong assumption about the expected value for PIDs buffer size. This change adds some small manual code that converts the input slice length to the number of bytes of the array backing the slice. A test is also added. It fails with the previous implementation. Fixes golang/go#60223 Change-Id: I5e2414acb29c6c949e5e6acd328043f8a8883887
Implementation generated directly with mkwinsyscall has a wrong assumption about the expected value for PIDs buffer size. This change adds some small manual code that converts the input slice length to the number of bytes of the array backing the slice. A test is also added. It fails with the previous implementation. Fixes golang/go#60223 Change-Id: I5e2414acb29c6c949e5e6acd328043f8a8883887
Sorry if it's the wrong place to report, but I don't see another place to discuss an issue with
golang.org/x/sys
.What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, it's a problem with a separate module.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Calling
windows.EnumProcesses
with a slice[1024]uint32
as the first argument does not result in passing 4096 as the size of the input array. Instead, thelen()
of the slice is used, cutting the size to 1024 bytes.The code that generates the
windows.EnumProcesses
function does not take into account the discrepancy between the input slice type and what the system call expects ([]uint32
vs a byte array).What did you expect to see?
windows.EnumProcesses
should passlen(processIds)*4
as the input array size to the Windows system call.What did you see instead?
len(processIds)
is used instead:https://github.com/golang/sys/blob/1911637744c199cdad74ee1ee74d19ce61e3d9fa/windows/zsyscall_windows.go#L3524
The text was updated successfully, but these errors were encountered: