From 611d5d643895a3f69961c3287e39b9e8bca49330 Mon Sep 17 00:00:00 2001 From: Hao Mou Date: Fri, 29 Oct 2021 12:00:51 +0800 Subject: [PATCH] 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 TryBot-Result: Go Bot Reviewed-by: Alex Brainman Trust: Alex Brainman Trust: Cuong Manh Le --- windows/syscall_windows_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index 45836c96..b24d8658 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -922,7 +922,7 @@ func TestNtCreateFileAndNtSetInformationFile(t *testing.T) { 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)