aboutsummaryrefslogtreecommitdiffstats
path: root/prog/rand_test.go
diff options
context:
space:
mode:
authorGreg Steuck <blackgnezdo@gmail.com>2018-11-27 04:16:05 -0800
committerDmitry Vyukov <dvyukov@google.com>2018-11-27 13:16:05 +0100
commit0b29b7f95253d645475f4cc66a74f653437fa72d (patch)
treeb1ec00ce49d96d04a9606f6745ffcf9a1534c9d3 /prog/rand_test.go
parent6419afbb779b26af853b46d8ad79cfe52b6f7805 (diff)
prog: prevent sandbox escaping files from entering s.files
Diffstat (limited to 'prog/rand_test.go')
-rw-r--r--prog/rand_test.go26
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)
+ }
+ }
+}