diff options
Diffstat (limited to 'src/encoding/gob/decoder.go')
| -rw-r--r-- | src/encoding/gob/decoder.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/encoding/gob/decoder.go b/src/encoding/gob/decoder.go index 3a769ec125..dcad7a0e48 100644 --- a/src/encoding/gob/decoder.go +++ b/src/encoding/gob/decoder.go @@ -13,6 +13,11 @@ 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 + // A Decoder manages the receipt of type and data information read from the // remote side of a connection. type Decoder struct { @@ -75,9 +80,7 @@ func (dec *Decoder) recvMessage() bool { dec.err = err return false } - // 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 { + if nbytes >= tooBig { dec.err = errBadCount return false } |
