From 24fc64028c0faa7fcbdae2bf2a2ded825713c982 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Mon, 14 Nov 2022 10:21:51 -0800 Subject: [PATCH] os: don't request read access from CreateFile in Stat CL 448897 changed os.Stat to request GENERIC_READ access when using CreateFile to examine a file. This is unnecessary; access flags of 0 will permit examining file metadata even if the file isn't readable. Revert to the old behavior here. For #56217 Change-Id: I09220b3bbee304bd89f4a94ec9b0af42042b7773 Reviewed-on: https://go-review.googlesource.com/c/go/+/450296 TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Run-TryBot: Bryan Mills Run-TryBot: Quim Muntal --- src/os/stat_windows.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/os/stat_windows.go b/src/os/stat_windows.go index 4116e77170..f8f229c709 100644 --- a/src/os/stat_windows.go +++ b/src/os/stat_windows.go @@ -69,12 +69,8 @@ func stat(funcname, name string, createFileAttrs uint32) (FileInfo, error) { } // Finally use CreateFile. - h, err := syscall.CreateFile(namep, - syscall.GENERIC_READ, - syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE, - nil, - syscall.OPEN_EXISTING, - createFileAttrs, 0) + h, err := syscall.CreateFile(namep, 0, 0, nil, + syscall.OPEN_EXISTING, createFileAttrs, 0) if err != nil { return nil, &PathError{Op: "CreateFile", Path: name, Err: err} } -- 2.50.0