diff options
| author | Greg Steuck <blackgnezdo@gmail.com> | 2018-11-27 04:16:05 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-11-27 13:16:05 +0100 |
| commit | 0b29b7f95253d645475f4cc66a74f653437fa72d (patch) | |
| tree | b1ec00ce49d96d04a9606f6745ffcf9a1534c9d3 /prog/rand_test.go | |
| parent | 6419afbb779b26af853b46d8ad79cfe52b6f7805 (diff) | |
prog: prevent sandbox escaping files from entering s.files
Diffstat (limited to 'prog/rand_test.go')
| -rw-r--r-- | prog/rand_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/prog/rand_test.go b/prog/rand_test.go new file mode 100644 index 000000000..1771a0052 --- /dev/null +++ b/prog/rand_test.go @@ -0,0 +1,26 @@ +// Copyright 2018 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package prog + +import ( + "math/rand" + "testing" +) + +func TestNotEscaping(t *testing.T) { + r := newRand(nil, rand.NewSource(0)) + s := &state{ + files: map[string]bool{"./file0": true}, + } + bound := 1000000 + if testing.Short() { + bound = 1000 + } + for i := 0; i < bound; i++ { + fn := r.filenameImpl(s) + if escapingFilename(fn) { + t.Errorf("sandbox escaping file name %q", fn) + } + } +} |
