Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syscall: simplify O_TRUNC handling on Windows
The current implementation of O_TRUNC in syscall.Open on Windows is prone to TOCTOU issues, as it opens the file twice if the first open detects that the file doesn't exist. The file could be created in between the two open calls, leading to the creation of a new file with the undesired readonly attribute. This CL implements O_TRUNC by just calling CreateFile once without taking O_TRUNCATE into account, and then using Ftruncate if O_TRUNC is set to truncate the file. Updates #38225. Change-Id: Ic3ad1bab75c9a1c16f99c8c5bed867c5dbc3a23b Reviewed-on: https://go-review.googlesource.com/c/go/+/618836 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
- Loading branch information