windows: fix test causing checkptr failure
TestNtCreateFileAndNtSetInformationFile is failing checkptr. Fix by
using replacing [:] with [:n:n].
Fixes golang/go#49217
Change-Id: I08e7ed41b33452c096cf40cdbf9d73989b769bdb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359496
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go
index 45836c9..b24d865 100644
--- a/windows/syscall_windows_test.go
+++ b/windows/syscall_windows_test.go
@@ -922,7 +922,7 @@
typedBufferPtr := (*fileRenameInformation)(unsafe.Pointer(&buffer[0]))
typedBufferPtr.ReplaceIfExists = windows.FILE_RENAME_REPLACE_IF_EXISTS | windows.FILE_RENAME_POSIX_SEMANTICS
typedBufferPtr.FileNameLength = uint32(fileNameLen)
- copy((*[1 << 29]uint16)(unsafe.Pointer(&typedBufferPtr.FileName[0]))[:], newNameUTF16)
+ copy((*[windows.MAX_LONG_PATH]uint16)(unsafe.Pointer(&typedBufferPtr.FileName[0]))[:fileNameLen/2:fileNameLen/2], newNameUTF16)
err = windows.NtSetInformationFile(fileHandle, &iosb, &buffer[0], uint32(bufferSize), windows.FileRenameInformation)
if err != nil {
t.Fatalf("NtSetInformationFile(%v) failed: %v", newPath, err)