diff options
author | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2022-04-22 10:07:51 +0900 |
---|---|---|
committer | Dmitri Shuralyov <dmitshur@golang.org> | 2022-05-31 17:30:12 +0000 |
commit | 4c69fd51a9ed70da0a6399d0b084b828bc30d562 (patch) | |
tree | aa54f6a3c29412a401cb050f588b8fe120ebff46 /src/path/filepath/path_windows_test.go | |
parent | 909881db03b7aca794c791e4c6e893c9a4638521 (diff) | |
download | go-4c69fd51a9ed70da0a6399d0b084b828bc30d562.tar.gz go-4c69fd51a9ed70da0a6399d0b084b828bc30d562.zip |
[release-branch.go1.17] path/filepath: do not remove prefix "." when following path contains ":".
For #52476
Fixes #52478
Fixes CVE-2022-29804
Change-Id: I9eb72ac7dbccd6322d060291f31831dc389eb9bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/401595
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/405235
Reviewed-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Diffstat (limited to 'src/path/filepath/path_windows_test.go')
-rw-r--r-- | src/path/filepath/path_windows_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go index 76a459ac96..3edafb5a85 100644 --- a/src/path/filepath/path_windows_test.go +++ b/src/path/filepath/path_windows_test.go @@ -530,3 +530,29 @@ func TestNTNamespaceSymlink(t *testing.T) { t.Errorf(`EvalSymlinks(%q): got %q, want %q`, filelink, got, want) } } + +func TestIssue52476(t *testing.T) { + tests := []struct { + lhs, rhs string + want string + }{ + {`..\.`, `C:`, `..\C:`}, + {`..`, `C:`, `..\C:`}, + {`.`, `:`, `:`}, + {`.`, `C:`, `.\C:`}, + {`.`, `C:/a/b/../c`, `.\C:\a\c`}, + {`.`, `\C:`, `.\C:`}, + {`C:\`, `.`, `C:\`}, + {`C:\`, `C:\`, `C:\C:`}, + {`C`, `:`, `C\:`}, + {`\.`, `C:`, `\C:`}, + {`\`, `C:`, `\C:`}, + } + + for _, test := range tests { + got := filepath.Join(test.lhs, test.rhs) + if got != test.want { + t.Errorf(`Join(%q, %q): got %q, want %q`, test.lhs, test.rhs, got, test.want) + } + } +} |