]> Cypherpunks.ru repositories - gostls13.git/commit
path/filepath: do not Clean("a/../c:/b") into c:\b on Windows
authorDamien Neil <dneil@google.com>
Tue, 13 Dec 2022 00:43:37 +0000 (16:43 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 14 Feb 2023 16:51:16 +0000 (16:51 +0000)
commit95eb5abd6340b271ae728f99986eeccbc0354ab1
tree1d964b7dd47b4083a61eb0deabe1833c2635401e
parent117fe2e08d2fb385e4febed020b834d2d8e4358a
path/filepath: do not Clean("a/../c:/b") into c:\b on Windows

Do not permit Clean to convert a relative path into one starting
with a drive reference. This change causes Clean to insert a .
path element at the start of a path when the original path does not
start with a volume name, and the first path element would contain
a colon.

This may introduce a spurious but harmless . path element under
some circumstances. For example, Clean("a/../b:/../c") becomes `.\c`.

This reverts CL 401595, since the change here supersedes the one
in that CL.

Thanks to RyotaK (https://twitter.com/ryotkak) for reporting this issue.

Fixes #57274
Fixes CVE-2022-41722

Change-Id: I837446285a03aa74c79d7642720e01f354c2ca17
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1675249
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468123
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/path/filepath/path.go
src/path/filepath/path_test.go
src/path/filepath/path_windows_test.go