summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorSakib Sajal <sakib.sajal@windriver.com>2021-07-30 15:54:39 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-08-06 09:59:14 +0100
commita21c4c48b84a01453c252ab19b9d50ad257f348f (patch)
tree04955d9148b511df2d387162303f222ea90a34dc /meta/recipes-devtools
parentad768575b136ace44690145c2ec2a0b9551b1d48 (diff)
downloadpoky-a21c4c48b84a01453c252ab19b9d50ad257f348f.tar.gz
go: fix CVE-2020-29509, CVE-2020-29511
Backport patch to fix CVE-2020-29509, CVE-2020-29511 (From OE-Core rev: db6dc9aa669d1f41fb52685754c07fe5c9feec86) Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/go/go-1.16.5.inc1
-rw-r--r--meta/recipes-devtools/go/go-1.16/0001-encoding-xml-handle-leading-trailing-or-double-colon.patch123
2 files changed, 124 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.16.5.inc b/meta/recipes-devtools/go/go-1.16.5.inc
index bd928e44f8..b693315917 100644
--- a/meta/recipes-devtools/go/go-1.16.5.inc
+++ b/meta/recipes-devtools/go/go-1.16.5.inc
@@ -16,5 +16,6 @@ SRC_URI += "\
16 file://0007-cmd-go-make-GOROOT-precious-by-default.patch \ 16 file://0007-cmd-go-make-GOROOT-precious-by-default.patch \
17 file://0008-use-GOBUILDMODE-to-set-buildmode.patch \ 17 file://0008-use-GOBUILDMODE-to-set-buildmode.patch \
18 file://0009-Revert-cmd-go-make-sure-CC-and-CXX-are-absolute.patch \ 18 file://0009-Revert-cmd-go-make-sure-CC-and-CXX-are-absolute.patch \
19 file://0001-encoding-xml-handle-leading-trailing-or-double-colon.patch \
19" 20"
20SRC_URI[main.sha256sum] = "7bfa7e5908c7cc9e75da5ddf3066d7cbcf3fd9fa51945851325eebc17f50ba80" 21SRC_URI[main.sha256sum] = "7bfa7e5908c7cc9e75da5ddf3066d7cbcf3fd9fa51945851325eebc17f50ba80"
diff --git a/meta/recipes-devtools/go/go-1.16/0001-encoding-xml-handle-leading-trailing-or-double-colon.patch b/meta/recipes-devtools/go/go-1.16/0001-encoding-xml-handle-leading-trailing-or-double-colon.patch
new file mode 100644
index 0000000000..3c47157d1a
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.16/0001-encoding-xml-handle-leading-trailing-or-double-colon.patch
@@ -0,0 +1,123 @@
1From 4d014e723165f28b34458edb4aa9136e0fb4c702 Mon Sep 17 00:00:00 2001
2From: Filippo Valsorda <filippo@golang.org>
3Date: Tue, 27 Oct 2020 00:17:15 +0100
4Subject: [PATCH] encoding/xml: handle leading, trailing, or double colons in
5 names
6
7Before this change, <:name> would parse as <name>, which could cause
8issues in applications that rely on the parse-encode cycle to
9round-trip. Similarly, <x name:=""> would parse as expected but then
10have the attribute dropped when serializing because its name was empty.
11Finally, <a:b:c> would parse and get serialized incorrectly. All these
12values are invalid XML, but to minimize the impact of this change, we
13parse them whole into Name.Local.
14
15This issue was reported by Juho Nurminen of Mattermost as it leads to
16round-trip mismatches. See #43168. It's not being fixed in a security
17release because round-trip stability is not a currently supported
18security property of encoding/xml, and we don't believe these fixes
19would be sufficient to reliably guarantee it in the future.
20
21Fixes CVE-2020-29509
22Fixes CVE-2020-29511
23Updates #43168
24
25Change-Id: I68321c4d867305046f664347192948a889af3c7f
26Reviewed-on: https://go-review.googlesource.com/c/go/+/277892
27Run-TryBot: Filippo Valsorda <filippo@golang.org>
28TryBot-Result: Go Bot <gobot@golang.org>
29Trust: Filippo Valsorda <filippo@golang.org>
30Reviewed-by: Katie Hockman <katie@golang.org>
31
32CVE: CVE-2020-29509 CVE-2020-29511
33Upstream-Status: Backport [4d014e723165f28b34458edb4aa9136e0fb4c702]
34
35Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
36---
37 src/encoding/xml/xml.go | 5 ++--
38 src/encoding/xml/xml_test.go | 56 ++++++++++++++++++++++++++++++++++++
39 2 files changed, 59 insertions(+), 2 deletions(-)
40
41diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
42index 384d6ad4b8..c902f1295a 100644
43--- a/src/encoding/xml/xml.go
44+++ b/src/encoding/xml/xml.go
45@@ -1156,8 +1156,9 @@ func (d *Decoder) nsname() (name Name, ok bool) {
46 if !ok {
47 return
48 }
49- i := strings.Index(s, ":")
50- if i < 0 {
51+ if strings.Count(s, ":") > 1 {
52+ name.Local = s
53+ } else if i := strings.Index(s, ":"); i < 1 || i > len(s)-2 {
54 name.Local = s
55 } else {
56 name.Space = s[0:i]
57diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go
58index 5a10f5309d..47d0c39167 100644
59--- a/src/encoding/xml/xml_test.go
60+++ b/src/encoding/xml/xml_test.go
61@@ -1003,3 +1003,59 @@ func TestTokenUnmarshaler(t *testing.T) {
62 d := NewTokenDecoder(tokReader{})
63 d.Decode(&Failure{})
64 }
65+
66+func testRoundTrip(t *testing.T, input string) {
67+ d := NewDecoder(strings.NewReader(input))
68+ var tokens []Token
69+ var buf bytes.Buffer
70+ e := NewEncoder(&buf)
71+ for {
72+ tok, err := d.Token()
73+ if err == io.EOF {
74+ break
75+ }
76+ if err != nil {
77+ t.Fatalf("invalid input: %v", err)
78+ }
79+ if err := e.EncodeToken(tok); err != nil {
80+ t.Fatalf("failed to re-encode input: %v", err)
81+ }
82+ tokens = append(tokens, CopyToken(tok))
83+ }
84+ if err := e.Flush(); err != nil {
85+ t.Fatal(err)
86+ }
87+
88+ d = NewDecoder(&buf)
89+ for {
90+ tok, err := d.Token()
91+ if err == io.EOF {
92+ break
93+ }
94+ if err != nil {
95+ t.Fatalf("failed to decode output: %v", err)
96+ }
97+ if len(tokens) == 0 {
98+ t.Fatalf("unexpected token: %#v", tok)
99+ }
100+ a, b := tokens[0], tok
101+ if !reflect.DeepEqual(a, b) {
102+ t.Fatalf("token mismatch: %#v vs %#v", a, b)
103+ }
104+ tokens = tokens[1:]
105+ }
106+ if len(tokens) > 0 {
107+ t.Fatalf("lost tokens: %#v", tokens)
108+ }
109+}
110+
111+func TestRoundTrip(t *testing.T) {
112+ tests := map[string]string{
113+ "leading colon": `<::Test ::foo="bar"><:::Hello></:::Hello><Hello></Hello></::Test>`,
114+ "trailing colon": `<foo abc:="x"></foo>`,
115+ "double colon": `<x:y:foo></x:y:foo>`,
116+ }
117+ for name, input := range tests {
118+ t.Run(name, func(t *testing.T) { testRoundTrip(t, input) })
119+ }
120+}
121--
1222.25.1
123