Browse code

Adding test case for symlink causes infinit loop, reproduces: dotcloud#5370

normally symlinks are created as either
ln -s /path/existing /path/new-name
or
cd /path && ln -s ./existing new-name

but one can create it this way
cd /path && ln -s existing new-name

this drives FollowSymlinkInScope into infinite loop

Docker-DCO-1.1-Signed-off-by: Lajos Papp <lajos.papp@sequenceiq.com> (github: lalyos)

lalyos authored on 2014/05/16 06:52:36
Showing 2 changed files
... ...
@@ -28,6 +28,19 @@ func TestFollowSymLinkNormal(t *testing.T) {
28 28
 	}
29 29
 }
30 30
 
31
+func TestFollowSymLinkRelativePath(t *testing.T) {
32
+	link := "testdata/fs/i"
33
+
34
+	rewrite, err := FollowSymlinkInScope(link, "testdata")
35
+	if err != nil {
36
+		t.Fatal(err)
37
+	}
38
+
39
+	if expected := abs(t, "testdata/fs/a"); expected != rewrite {
40
+		t.Fatalf("Expected %s got %s", expected, rewrite)
41
+	}
42
+}
43
+
31 44
 func TestFollowSymLinkUnderLinkedDir(t *testing.T) {
32 45
 	dir, err := ioutil.TempDir("", "docker-fs-test")
33 46
 	if err != nil {
34 47
new file mode 120000
... ...
@@ -0,0 +1 @@
0
+a
0 1
\ No newline at end of file