diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-08-09 12:40:58 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-08-10 11:45:49 +0200 |
| commit | 8fad22bf840fc968171bee6cf294f026eb1e0d3a (patch) | |
| tree | 2bad644606904f4e75ef6fe689bac49e91877c40 /prog/mutation.go | |
| parent | a12254451cfa5e5129a0c091255d502b6805adf6 (diff) | |
prog: generate very long file names
Generate very long file names once in a while to provoke bugs like:
https://github.com/google/gvisor/commit/f857f268eceb1cdee0b2bdfa218c969c84033fcd
Diffstat (limited to 'prog/mutation.go')
| -rw-r--r-- | prog/mutation.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/prog/mutation.go b/prog/mutation.go index 022ebce62..b03987671 100644 --- a/prog/mutation.go +++ b/prog/mutation.go @@ -333,7 +333,11 @@ func (t *BufferType) mutate(r *randGen, s *state, arg Arg, ctx ArgCtx) (calls [] } a := arg.(*DataArg) if a.Dir() == DirOut { - mutateBufferSize(r, a, minLen, maxLen) + if t.Kind == BufferFilename && r.oneOf(100) { + a.size = uint64(r.randFilenameLength()) + } else { + mutateBufferSize(r, a, minLen, maxLen) + } return } switch t.Kind { @@ -370,7 +374,8 @@ func (t *BufferType) mutate(r *randGen, s *state, arg Arg, ctx ArgCtx) (calls [] func mutateBufferSize(r *randGen, arg *DataArg, minLen, maxLen uint64) { for oldSize := arg.Size(); oldSize == arg.Size(); { arg.size += uint64(r.Intn(33)) - 16 - if arg.size < minLen { + // Cast to int64 to prevent underflows. + if int64(arg.size) < int64(minLen) { arg.size = minLen } if arg.size > maxLen { |
