Skip to content

Commit

Permalink
prog: fix crash in blob mutation
Browse files Browse the repository at this point in the history
If we deserialized a huge blob (larger than max blob size),
then we can get a negative size in the "Insert random bytes" case at:

		if r := int(maxLen) - len(data); n > r {
			n = r
		}

Don't insert bytes if data is already larger than maxLen.
  • Loading branch information
dvyukov committed Jul 26, 2019
1 parent cf49ed5 commit 3e5d1be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion prog/mutation.go
Expand Up @@ -465,7 +465,7 @@ var mutateDataFuncs = [...]func(r *randGen, data []byte, minLen, maxLen uint64)
},
// Insert random bytes.
func(r *randGen, data []byte, minLen, maxLen uint64) ([]byte, bool) {
if len(data) == 0 {
if len(data) == 0 || uint64(len(data)) >= maxLen {
return data, false
}
n := r.Intn(16) + 1
Expand Down

0 comments on commit 3e5d1be

Please sign in to comment.