aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/read_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/xml/read_test.go')
-rw-r--r--src/encoding/xml/read_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/encoding/xml/read_test.go b/src/encoding/xml/read_test.go
index 6ef55de77b..42059db3ae 100644
--- a/src/encoding/xml/read_test.go
+++ b/src/encoding/xml/read_test.go
@@ -5,6 +5,8 @@
package xml
import (
+ "bytes"
+ "errors"
"io"
"reflect"
"strings"
@@ -1094,3 +1096,16 @@ func TestUnmarshalIntoNil(t *testing.T) {
}
}
+
+func TestCVE202228131(t *testing.T) {
+ type nested struct {
+ Parent *nested `xml:",any"`
+ }
+ var n nested
+ err := Unmarshal(bytes.Repeat([]byte("<a>"), maxUnmarshalDepth+1), &n)
+ if err == nil {
+ t.Fatal("Unmarshal did not fail")
+ } else if !errors.Is(err, errExeceededMaxUnmarshalDepth) {
+ t.Fatalf("Unmarshal unexpected error: got %q, want %q", err, errExeceededMaxUnmarshalDepth)
+ }
+}