summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go-1.14/CVE-2022-41725-pre1.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/go/go-1.14/CVE-2022-41725-pre1.patch')
-rw-r--r--meta/recipes-devtools/go/go-1.14/CVE-2022-41725-pre1.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2022-41725-pre1.patch b/meta/recipes-devtools/go/go-1.14/CVE-2022-41725-pre1.patch
new file mode 100644
index 0000000000..37ebc41947
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.14/CVE-2022-41725-pre1.patch
@@ -0,0 +1,85 @@
1From 874b3132a84cf76da6a48978826c04c380a37a50 Mon Sep 17 00:00:00 2001
2From: avivklas <avivklas@gmail.com>
3Date: Fri, 7 Aug 2020 21:50:12 +0300
4Subject: [PATCH] mime/multipart: return overflow errors in Reader.ReadForm
5
6Updates Reader.ReadForm to check for overflow errors that may
7result from a leeway addition of 10MiB to the input argument
8maxMemory.
9
10Fixes #40430
11
12Change-Id: I510b8966c95c51d04695ba9d08fcfe005fd11a5d
13Reviewed-on: https://go-review.googlesource.com/c/go/+/247477
14Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
15Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
16Trust: Emmanuel Odeke <emm.odeke@gmail.com>
17TryBot-Result: Go Bot <gobot@golang.org>
18Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
19
20Upstream-Status: Backport [https://github.com/golang/go/commit/874b3132a84cf76da6a48978826c04c380a37a50]
21CVE: CVE-2022-41725 #Dependency Patch1
22Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
23---
24 src/mime/multipart/formdata.go | 4 ++++
25 src/mime/multipart/formdata_test.go | 18 ++++++++++++++++++
26 2 files changed, 22 insertions(+)
27
28diff --git a/src/mime/multipart/formdata.go b/src/mime/multipart/formdata.go
29index 832d0ad693666..4eb31012941ac 100644
30--- a/src/mime/multipart/formdata.go
31+++ b/src/mime/multipart/formdata.go
32@@ -7,6 +7,7 @@ package multipart
33 import (
34 "bytes"
35 "errors"
36+ "fmt"
37 "io"
38 "io/ioutil"
39 "net/textproto"
40@@ -41,6 +42,9 @@ func (r *Reader) readForm(maxMemory int64) (_ *Form, err error) {
41
42 // Reserve an additional 10 MB for non-file parts.
43 maxValueBytes := maxMemory + int64(10<<20)
44+ if maxValueBytes <= 0 {
45+ return nil, fmt.Errorf("multipart: integer overflow from maxMemory(%d) + 10MiB for non-file parts", maxMemory)
46+ }
47 for {
48 p, err := r.NextPart()
49 if err == io.EOF {
50diff --git a/src/mime/multipart/formdata_test.go b/src/mime/multipart/formdata_test.go
51index 7d756c8c244a0..7112e0d3727fe 100644
52--- a/src/mime/multipart/formdata_test.go
53+++ b/src/mime/multipart/formdata_test.go
54@@ -7,6 +7,7 @@ package multipart
55 import (
56 "bytes"
57 "io"
58+ "math"
59 "os"
60 "strings"
61 "testing"
62@@ -52,6 +53,23 @@ func TestReadFormWithNamelessFile(t *testing.T) {
63 }
64 }
65
66+// Issue 40430: Ensure that we report integer overflows in additions of maxMemory,
67+// instead of silently and subtly failing without indication.
68+func TestReadFormMaxMemoryOverflow(t *testing.T) {
69+ b := strings.NewReader(strings.ReplaceAll(messageWithTextContentType, "\n", "\r\n"))
70+ r := NewReader(b, boundary)
71+ f, err := r.ReadForm(math.MaxInt64)
72+ if err == nil {
73+ t.Fatal("Unexpected a non-nil error")
74+ }
75+ if f != nil {
76+ t.Fatalf("Unexpected returned a non-nil form: %v\n", f)
77+ }
78+ if g, w := err.Error(), "integer overflow from maxMemory"; !strings.Contains(g, w) {
79+ t.Errorf(`Error mismatch\n%q\ndid not contain\n%q`, g, w)
80+ }
81+}
82+
83 func TestReadFormWithTextContentType(t *testing.T) {
84 // From https://github.com/golang/go/issues/24041
85 b := strings.NewReader(strings.ReplaceAll(messageWithTextContentType, "\n", "\r\n"))