summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go-1.14/CVE-2022-28131.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/go/go-1.14/CVE-2022-28131.patch')
-rw-r--r--meta/recipes-devtools/go/go-1.14/CVE-2022-28131.patch104
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2022-28131.patch b/meta/recipes-devtools/go/go-1.14/CVE-2022-28131.patch
new file mode 100644
index 0000000000..8afa292144
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.14/CVE-2022-28131.patch
@@ -0,0 +1,104 @@
1From 8136eb2e5c316a51d0da710fbd0504cbbefee526 Mon Sep 17 00:00:00 2001
2From: Roland Shoemaker <roland@golang.org>
3Date: Mon, 28 Mar 2022 18:41:26 -0700
4Subject: [PATCH] encoding/xml: use iterative Skip, rather than recursive
5
6Upstream-Status: Backport [https://github.com/golang/go/commit/58facfbe7db2fbb9afed794b281a70bdb12a60ae]
7CVE: CVE-2022-28131
8Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
9
10
11Prevents exhausting the stack limit in _incredibly_ deeply nested
12structures.
13
14Fixes #53711
15Updates #53614
16Fixes CVE-2022-28131
17
18Change-Id: I47db4595ce10cecc29fbd06afce7b299868599e6
19Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1419912
20Reviewed-by: Julie Qiu <julieqiu@google.com>
21Reviewed-by: Damien Neil <dneil@google.com>
22(cherry picked from commit 9278cb78443d2b4deb24cbb5b61c9ba5ac688d49)
23Reviewed-on: https://go-review.googlesource.com/c/go/+/417068
24TryBot-Result: Gopher Robot <gobot@golang.org>
25Reviewed-by: Heschi Kreinick <heschi@google.com>
26Run-TryBot: Michael Knyszek <mknyszek@google.com>
27---
28 src/encoding/xml/read.go | 15 ++++++++-------
29 src/encoding/xml/read_test.go | 18 ++++++++++++++++++
30 2 files changed, 26 insertions(+), 7 deletions(-)
31
32diff --git a/src/encoding/xml/read.go b/src/encoding/xml/read.go
33index 4ffed80..3fac859 100644
34--- a/src/encoding/xml/read.go
35+++ b/src/encoding/xml/read.go
36@@ -743,12 +743,12 @@ Loop:
37 }
38
39 // Skip reads tokens until it has consumed the end element
40-// matching the most recent start element already consumed.
41-// It recurs if it encounters a start element, so it can be used to
42-// skip nested structures.
43+// matching the most recent start element already consumed,
44+// skipping nested structures.
45 // It returns nil if it finds an end element matching the start
46 // element; otherwise it returns an error describing the problem.
47 func (d *Decoder) Skip() error {
48+ var depth int64
49 for {
50 tok, err := d.Token()
51 if err != nil {
52@@ -756,11 +756,12 @@ func (d *Decoder) Skip() error {
53 }
54 switch tok.(type) {
55 case StartElement:
56- if err := d.Skip(); err != nil {
57- return err
58- }
59+ depth++
60 case EndElement:
61- return nil
62+ if depth == 0 {
63+ return nil
64+ }
65+ depth--
66 }
67 }
68 }
69diff --git a/src/encoding/xml/read_test.go b/src/encoding/xml/read_test.go
70index 6a20b1a..7a621a5 100644
71--- a/src/encoding/xml/read_test.go
72+++ b/src/encoding/xml/read_test.go
73@@ -5,9 +5,11 @@
74 package xml
75
76 import (
77+ "bytes"
78 "errors"
79 "io"
80 "reflect"
81+ "runtime"
82 "strings"
83 "testing"
84 "time"
85@@ -1093,3 +1095,19 @@ func TestCVE202228131(t *testing.T) {
86 t.Fatalf("Unmarshal unexpected error: got %q, want %q", err, errExeceededMaxUnmarshalDepth)
87 }
88 }
89+
90+func TestCVE202230633(t *testing.T) {
91+ if runtime.GOARCH == "wasm" {
92+ t.Skip("causes memory exhaustion on js/wasm")
93+ }
94+ defer func() {
95+ p := recover()
96+ if p != nil {
97+ t.Fatal("Unmarshal panicked")
98+ }
99+ }()
100+ var example struct {
101+ Things []string
102+ }
103+ Unmarshal(bytes.Repeat([]byte("<a>"), 17_000_000), &example)
104+}