|
| 1 | +diff --git a/./vendor/gopkg.in/square/go-jose.v2/crypter.go b/../kubernetes/vendor/gopkg.in/square/go-jose.v2/crypter.go |
| 2 | +index be7433e..763eae0 100644 |
| 3 | +--- a/./vendor/gopkg.in/square/go-jose.v2/crypter.go |
| 4 | ++++ b/../kubernetes/vendor/gopkg.in/square/go-jose.v2/crypter.go |
| 5 | +@@ -406,6 +406,9 @@ func (ctx *genericEncrypter) Options() EncrypterOptions { |
| 6 | + // Decrypt and validate the object and return the plaintext. Note that this |
| 7 | + // function does not support multi-recipient, if you desire multi-recipient |
| 8 | + // decryption use DecryptMulti instead. |
| 9 | ++// |
| 10 | ++// Automatically decompresses plaintext, but returns an error if the decompressed |
| 11 | ++// data would be >250kB or >10x the size of the compressed data, whichever is larger. |
| 12 | + func (obj JSONWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error) { |
| 13 | + headers := obj.mergedHeaders(nil) |
| 14 | + |
| 15 | +@@ -470,6 +473,9 @@ func (obj JSONWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error) |
| 16 | + // with support for multiple recipients. It returns the index of the recipient |
| 17 | + // for which the decryption was successful, the merged headers for that recipient, |
| 18 | + // and the plaintext. |
| 19 | ++// |
| 20 | ++// Automatically decompresses plaintext, but returns an error if the decompressed |
| 21 | ++// data would be >250kB or >3x the size of the compressed data, whichever is larger. |
| 22 | + func (obj JSONWebEncryption) DecryptMulti(decryptionKey interface{}) (int, Header, []byte, error) { |
| 23 | + globalHeaders := obj.mergedHeaders(nil) |
| 24 | + |
| 25 | +diff --git a/./vendor/gopkg.in/square/go-jose.v2/encoding.go b/../kubernetes/vendor/gopkg.in/square/go-jose.v2/encoding.go |
| 26 | +index 70f7385..ab9e086 100644 |
| 27 | +--- a/./vendor/gopkg.in/square/go-jose.v2/encoding.go |
| 28 | ++++ b/../kubernetes/vendor/gopkg.in/square/go-jose.v2/encoding.go |
| 29 | +@@ -21,6 +21,7 @@ import ( |
| 30 | + "compress/flate" |
| 31 | + "encoding/base64" |
| 32 | + "encoding/binary" |
| 33 | ++ "fmt" |
| 34 | + "io" |
| 35 | + "math/big" |
| 36 | + "strings" |
| 37 | +@@ -85,7 +86,7 @@ func decompress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) { |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | +-// Compress with DEFLATE |
| 42 | ++// deflate compresses the input. |
| 43 | + func deflate(input []byte) ([]byte, error) { |
| 44 | + output := new(bytes.Buffer) |
| 45 | + |
| 46 | +@@ -97,15 +98,27 @@ func deflate(input []byte) ([]byte, error) { |
| 47 | + return output.Bytes(), err |
| 48 | + } |
| 49 | + |
| 50 | +-// Decompress with DEFLATE |
| 51 | ++// inflate decompresses the input. |
| 52 | ++// |
| 53 | ++// Errors if the decompressed data would be >250kB or >10x the size of the |
| 54 | ++// compressed data, whichever is larger. |
| 55 | + func inflate(input []byte) ([]byte, error) { |
| 56 | + output := new(bytes.Buffer) |
| 57 | + reader := flate.NewReader(bytes.NewBuffer(input)) |
| 58 | + |
| 59 | +- _, err := io.Copy(output, reader) |
| 60 | +- if err != nil { |
| 61 | ++ maxCompressedSize := 10 * int64(len(input)) |
| 62 | ++ if maxCompressedSize < 250000 { |
| 63 | ++ maxCompressedSize = 250000 |
| 64 | ++ } |
| 65 | ++ |
| 66 | ++ limit := maxCompressedSize + 1 |
| 67 | ++ n, err := io.CopyN(output, reader, limit) |
| 68 | ++ if err != nil && err != io.EOF { |
| 69 | + return nil, err |
| 70 | + } |
| 71 | ++ if n == limit { |
| 72 | ++ return nil, fmt.Errorf("uncompressed data would be too large (>%d bytes)", maxCompressedSize) |
| 73 | ++ } |
| 74 | + |
| 75 | + err = reader.Close() |
| 76 | + return output.Bytes(), err |
0 commit comments