encoding/gob: more hardening for lengths of input strings.

Fixes #3160.

R=r
CC=golang-dev
https://golang.org/cl/5716046
This commit is contained in:
David Symonds 2012-03-01 15:57:54 +11:00
parent 984780a589
commit 1f0f459a16
2 changed files with 21 additions and 7 deletions

View file

@ -1455,11 +1455,14 @@ func TestFuzz(t *testing.T) {
func TestFuzzRegressions(t *testing.T) {
// An instance triggering a type name of length ~102 GB.
testFuzz(t, 1328492090837718000, 100, new(float32))
// An instance triggering a type name of 1.6 GB.
// Commented out because it takes 5m to run.
//testFuzz(t, 1330522872628565000, 100, new(int))
}
func testFuzz(t *testing.T, seed int64, n int, input ...interface{}) {
t.Logf("seed=%d n=%d\n", seed, n)
for _, e := range input {
t.Logf("seed=%d n=%d e=%T", seed, n, e)
rng := rand.New(rand.NewSource(seed))
for i := 0; i < n; i++ {
encFuzzDec(rng, e)