Commit 6e1c0df1 authored by Rob Pike's avatar Rob Pike

gob: reduce the maximum message size

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
parent 387e7c27
...@@ -75,7 +75,9 @@ func (dec *Decoder) recvMessage() bool { ...@@ -75,7 +75,9 @@ func (dec *Decoder) recvMessage() bool {
dec.err = err dec.err = err
return false 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 dec.err = errBadCount
return false return false
} }
......
...@@ -547,7 +547,6 @@ func (a isZeroBugArray) GobEncode() (b []byte, e error) { ...@@ -547,7 +547,6 @@ func (a isZeroBugArray) GobEncode() (b []byte, e error) {
} }
func (a *isZeroBugArray) GobDecode(data []byte) error { func (a *isZeroBugArray) GobDecode(data []byte) error {
println("DECODE")
if len(data) != len(a) { if len(data) != len(a) {
return io.EOF return io.EOF
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment