Skip to content

Commit

Permalink
encoding/gob: increase "tooBig" from 1GB to 8GB on 64-bit machines
Browse files Browse the repository at this point in the history
A little shift magic makes it easy to adjust the maximum buffer
size on machines with larger integers.

Fixes golang#27635

Change-Id: I1f26b07a363fbb9730df2377052475fa88bbb781
Reviewed-on: https://go-review.googlesource.com/c/143678
Run-TryBot: Rob Pike <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
robpike committed Oct 22, 2018
1 parent 7c2718b commit 3bf9b77
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/encoding/gob/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3bf9b77

Please sign in to comment.