]> Cypherpunks repositories - gostls13.git/commitdiff
gob: reduce the maximum message size
authorRob Pike <r@golang.org>
Sun, 22 Jan 2012 20:01:12 +0000 (12:01 -0800)
committerRob Pike <r@golang.org>
Sun, 22 Jan 2012 20:01:12 +0000 (12:01 -0800)
It was 2^31, but that could cause overflow and trouble.
Reduce it to 2^30 and add a TODO.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5562049

src/pkg/encoding/gob/decoder.go
src/pkg/encoding/gob/gobencdec_test.go

index 5e684d3ee7eba49ab243fc4674b8f8aa9be8bb5f..fb28c8caf53561f24791fbef614e5d4a168d3947 100644 (file)
@@ -75,7 +75,9 @@ func (dec *Decoder) recvMessage() bool {
                dec.err = err
                return false
        }
-       if nbytes >= 1<<31 {
+       // Upper limit of 1GB, allowing room to grow a little without overflow.
+       // TODO: We might want more control over this limit.
+       if nbytes >= 1<<30 {
                dec.err = errBadCount
                return false
        }
index b8dfeeb5156d0e066794ef749c3a6df588b8006d..83644c0331b426437888e3579dba1e3a760fac57 100644 (file)
@@ -547,7 +547,6 @@ func (a isZeroBugArray) GobEncode() (b []byte, e error) {
 }
 
 func (a *isZeroBugArray) GobDecode(data []byte) error {
-       println("DECODE")
        if len(data) != len(a) {
                return io.EOF
        }