]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/gob: increase "tooBig" from 1GB to 8GB on 64-bit machines
authorRob Pike <r@golang.org>
Mon, 22 Oct 2018 03:17:06 +0000 (14:17 +1100)
committerRob Pike <r@golang.org>
Mon, 22 Oct 2018 05:45:18 +0000 (05:45 +0000)
A little shift magic makes it easy to adjust the maximum buffer
size on machines with larger integers.

Fixes #27635

Change-Id: I1f26b07a363fbb9730df2377052475fa88bbb781
Reviewed-on: https://go-review.googlesource.com/c/143678
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/encoding/gob/decoder.go

index 5ef03888621146da0d1f397ab7464a3ffa728429..f4f740ef4227cd5b6b2f9e8b10fe0882239f45cf 100644 (file)
@@ -12,10 +12,10 @@ import (
        "sync"
 )
 
-// tooBig provides a sanity check for sizes; used in several places.
-// Upper limit of 1GB, allowing room to grow a little without overflow.
-// TODO: make this adjustable?
-const tooBig = 1 << 30
+// tooBig provides a sanity check for sizes; used in several places. Upper limit
+// of is 1GB on 32-bit systems, 8GB on 64-bit, allowing room to grow a little
+// without overflow.
+const tooBig = (1 << 30) << (^uint(0) >> 62)
 
 // A Decoder manages the receipt of type and data information read from the
 // remote side of a connection.