Skip to content

Commit bb5075a

Browse files
committed
syscall: remove RtlGenRandom and move it into internal/syscall
There's on need to expose this to the frozen syscall package, and it also doesn't need to be unsafe. So we move it into internal/syscall and have the generator make a safer function signature. Fixes #43704. Change-Id: Iccae69dc273a0aa97ee6846eb537f1dc1412f2de Reviewed-on: https://go-review.googlesource.com/c/go/+/283992 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Trust: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 1deae0b commit bb5075a

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

api/go1.16.txt

-2
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,8 @@ pkg syscall (linux-arm-cgo), func AllThreadsSyscall(uintptr, uintptr, uintptr, u
430430
pkg syscall (linux-arm-cgo), func AllThreadsSyscall6(uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) (uintptr, uintptr, Errno)
431431
pkg syscall (linux-arm-cgo), func Setegid(int) error
432432
pkg syscall (linux-arm-cgo), func Seteuid(int) error
433-
pkg syscall (windows-386), func RtlGenRandom(*uint8, uint32) error
434433
pkg syscall (windows-386), method (*DLLError) Unwrap() error
435434
pkg syscall (windows-386), type SysProcAttr struct, NoInheritHandles bool
436-
pkg syscall (windows-amd64), func RtlGenRandom(*uint8, uint32) error
437435
pkg syscall (windows-amd64), method (*DLLError) Unwrap() error
438436
pkg syscall (windows-amd64), type SysProcAttr struct, NoInheritHandles bool
439437
pkg testing/fstest, func TestFS(fs.FS, ...string) error

src/crypto/rand/rand_windows.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
package rand
99

1010
import (
11+
"internal/syscall/windows"
1112
"os"
12-
"syscall"
1313
)
1414

1515
func init() { Reader = &rngReader{} }
@@ -24,7 +24,7 @@ func (r *rngReader) Read(b []byte) (n int, err error) {
2424
return 0, nil
2525
}
2626

27-
err = syscall.RtlGenRandom(&b[0], inputLen)
27+
err = windows.RtlGenRandom(b)
2828
if err != nil {
2929
return 0, os.NewSyscallError("RtlGenRandom", err)
3030
}

src/internal/syscall/windows/syscall_windows.go

+2
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,5 @@ func LoadGetFinalPathNameByHandle() error {
342342

343343
//sys CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error) = userenv.CreateEnvironmentBlock
344344
//sys DestroyEnvironmentBlock(block *uint16) (err error) = userenv.DestroyEnvironmentBlock
345+
346+
//sys RtlGenRandom(buf []byte) (err error) = advapi32.SystemFunction036

src/internal/syscall/windows/zsyscall_windows.go

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/syscall/syscall_windows.go

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ func NewCallbackCDecl(fn interface{}) uintptr {
234234
//sys CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) = advapi32.CryptAcquireContextW
235235
//sys CryptReleaseContext(provhandle Handle, flags uint32) (err error) = advapi32.CryptReleaseContext
236236
//sys CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) = advapi32.CryptGenRandom
237-
//sys RtlGenRandom(buf *uint8, bytes uint32) (err error) = advapi32.SystemFunction036
238237
//sys GetEnvironmentStrings() (envs *uint16, err error) [failretval==nil] = kernel32.GetEnvironmentStringsW
239238
//sys FreeEnvironmentStrings(envs *uint16) (err error) = kernel32.FreeEnvironmentStringsW
240239
//sys GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) = kernel32.GetEnvironmentVariableW

src/syscall/zsyscall_windows.go

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)