summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch')
-rw-r--r--meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch b/meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch
new file mode 100644
index 0000000000..e1c9e0bdb9
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch
@@ -0,0 +1,65 @@
1From a0bf4d38dc2057d28396594264bbdd43d412de22 Mon Sep 17 00:00:00 2001
2From: Filippo Valsorda <filippo@golang.org>
3Date: Tue, 27 Oct 2020 00:21:30 +0100
4Subject: [PATCH] encoding/xml: replace comments inside directives with a space
5
6A Directive (like <!ENTITY xxx []>) can't have other nodes nested inside
7it (in our data structure representation), so there is no way to
8preserve comments. The previous behavior was to just elide them, which
9however might change the semantic meaning of the surrounding markup.
10Instead, replace them with a space which hopefully has the same semantic
11effect of the comment.
12
13Directives are not actually a node type in the XML spec, which instead
14specifies each of them separately (<!ENTITY, <!DOCTYPE, etc.), each with
15its own grammar. The rules for where and when the comments are allowed
16are not straightforward, and can't be implemented without implementing
17custom logic for each of the directives.
18
19Simply preserving the comments in the body of the directive would be
20problematic, as there can be unmatched quotes inside the comment.
21Whether those quotes are considered meaningful semantically or not,
22other parsers might disagree and interpret the output differently.
23
24This issue was reported by Juho Nurminen of Mattermost as it leads to
25round-trip mismatches. See #43168. It's not being fixed in a security
26release because round-trip stability is not a currently supported
27security property of encoding/xml, and we don't believe these fixes
28would be sufficient to reliably guarantee it in the future.
29
30Fixes CVE-2020-29510
31Updates #43168
32
33Change-Id: Icd86c75beff3e1e0689543efebdad10ed5178ce3
34Reviewed-on: https://go-review.googlesource.com/c/go/+/277893
35Run-TryBot: Filippo Valsorda <filippo@golang.org>
36TryBot-Result: Go Bot <gobot@golang.org>
37Trust: Filippo Valsorda <filippo@golang.org>
38Reviewed-by: Katie Hockman <katie@golang.org>
39
40Upstream-Status: Backport from https://github.com/golang/go/commit/a9cfd55e2b09735a25976d1b008a0a3c767494f8
41CVE: CVE-2020-29510
42Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
43---
44 src/encoding/xml/xml.go | 6 ++++++
45 1 file changed, 6 insertions(+)
46
47diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
48index 01a1460..98647b2 100644
49--- a/src/encoding/xml/xml.go
50+++ b/src/encoding/xml/xml.go
51@@ -768,6 +768,12 @@ func (d *Decoder) rawToken() (Token, error) {
52 }
53 b0, b1 = b1, b
54 }
55+
56+ // Replace the comment with a space in the returned Directive
57+ // body, so that markup parts that were separated by the comment
58+ // (like a "<" and a "!") don't get joined when re-encoding the
59+ // Directive, taking new semantic meaning.
60+ d.buf.WriteByte(' ')
61 }
62 }
63 return Directive(d.buf.Bytes()), nil
64--
652.7.4