diff options
Diffstat (limited to 'meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch')
-rw-r--r-- | meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch b/meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch new file mode 100644 index 0000000000..e1f7a55581 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch | |||
@@ -0,0 +1,104 @@ | |||
1 | From b8803cb711ae163b8e67897deb6cf8c49702227c Mon Sep 17 00:00:00 2001 | ||
2 | From: Damien Neil <dneil@google.com> | ||
3 | Date: Mon, 12 Dec 2022 16:43:37 -0800 | ||
4 | Subject: [PATCH 2/2] path/filepath: do not Clean("a/../c:/b") into c:\b on | ||
5 | Windows | ||
6 | |||
7 | Do not permit Clean to convert a relative path into one starting | ||
8 | with a drive reference. This change causes Clean to insert a . | ||
9 | path element at the start of a path when the original path does not | ||
10 | start with a volume name, and the first path element would contain | ||
11 | a colon. | ||
12 | |||
13 | This may introduce a spurious but harmless . path element under | ||
14 | some circumstances. For example, Clean("a/../b:/../c") becomes `.\c`. | ||
15 | |||
16 | This reverts CL 401595, since the change here supersedes the one | ||
17 | in that CL. | ||
18 | |||
19 | Thanks to RyotaK (https://twitter.com/ryotkak) for reporting this issue. | ||
20 | |||
21 | Updates #57274 | ||
22 | Fixes #57276 | ||
23 | Fixes CVE-2022-41722 | ||
24 | |||
25 | Change-Id: I837446285a03aa74c79d7642720e01f354c2ca17 | ||
26 | Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1675249 | ||
27 | Reviewed-by: Roland Shoemaker <bracewell@google.com> | ||
28 | Run-TryBot: Damien Neil <dneil@google.com> | ||
29 | Reviewed-by: Julie Qiu <julieqiu@google.com> | ||
30 | TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com> | ||
31 | (cherry picked from commit 8ca37f4813ef2f64600c92b83f17c9f3ca6c03a5) | ||
32 | Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728944 | ||
33 | Run-TryBot: Roland Shoemaker <bracewell@google.com> | ||
34 | Reviewed-by: Tatiana Bradley <tatianabradley@google.com> | ||
35 | Reviewed-by: Damien Neil <dneil@google.com> | ||
36 | Reviewed-on: https://go-review.googlesource.com/c/go/+/468119 | ||
37 | Reviewed-by: Than McIntosh <thanm@google.com> | ||
38 | Run-TryBot: Michael Pratt <mpratt@google.com> | ||
39 | TryBot-Result: Gopher Robot <gobot@golang.org> | ||
40 | Auto-Submit: Michael Pratt <mpratt@google.com> | ||
41 | |||
42 | Upstream-Status: Backport from https://github.com/golang/go/commit/bdf07c2e168baf736e4c057279ca12a4d674f18c | ||
43 | CVE: CVE-2022-41722 | ||
44 | Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com> | ||
45 | --- | ||
46 | src/path/filepath/path.go | 27 ++++++++++++++------------- | ||
47 | 1 file changed, 14 insertions(+), 13 deletions(-) | ||
48 | |||
49 | diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go | ||
50 | index 92dc090..f0f095e 100644 | ||
51 | --- a/src/path/filepath/path.go | ||
52 | +++ b/src/path/filepath/path.go | ||
53 | @@ -14,6 +14,7 @@ package filepath | ||
54 | import ( | ||
55 | "errors" | ||
56 | "os" | ||
57 | + "runtime" | ||
58 | "sort" | ||
59 | "strings" | ||
60 | ) | ||
61 | @@ -116,21 +117,9 @@ func Clean(path string) string { | ||
62 | case os.IsPathSeparator(path[r]): | ||
63 | // empty path element | ||
64 | r++ | ||
65 | - case path[r] == '.' && r+1 == n: | ||
66 | + case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])): | ||
67 | // . element | ||
68 | r++ | ||
69 | - case path[r] == '.' && os.IsPathSeparator(path[r+1]): | ||
70 | - // ./ element | ||
71 | - r++ | ||
72 | - | ||
73 | - for r < len(path) && os.IsPathSeparator(path[r]) { | ||
74 | - r++ | ||
75 | - } | ||
76 | - if out.w == 0 && volumeNameLen(path[r:]) > 0 { | ||
77 | - // When joining prefix "." and an absolute path on Windows, | ||
78 | - // the prefix should not be removed. | ||
79 | - out.append('.') | ||
80 | - } | ||
81 | case path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])): | ||
82 | // .. element: remove to last separator | ||
83 | r += 2 | ||
84 | @@ -156,6 +145,18 @@ func Clean(path string) string { | ||
85 | if rooted && out.w != 1 || !rooted && out.w != 0 { | ||
86 | out.append(Separator) | ||
87 | } | ||
88 | + // If a ':' appears in the path element at the start of a Windows path, | ||
89 | + // insert a .\ at the beginning to avoid converting relative paths | ||
90 | + // like a/../c: into c:. | ||
91 | + if runtime.GOOS == "windows" && out.w == 0 && out.volLen == 0 && r != 0 { | ||
92 | + for i := r; i < n && !os.IsPathSeparator(path[i]); i++ { | ||
93 | + if path[i] == ':' { | ||
94 | + out.append('.') | ||
95 | + out.append(Separator) | ||
96 | + break | ||
97 | + } | ||
98 | + } | ||
99 | + } | ||
100 | // copy element | ||
101 | for ; r < n && !os.IsPathSeparator(path[r]); r++ { | ||
102 | out.append(path[r]) | ||
103 | -- | ||
104 | 2.7.4 | ||