Skip to content

Commit

Permalink
Merge pull request #10238 from bacher09/fix-inf-loop
Browse files Browse the repository at this point in the history
Fix infinite loop in isPathOnVolume
  • Loading branch information
openshift-merge-robot authored May 7, 2021
2 parents 29b1317 + d6fd528 commit 41ac68d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/container_path_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func isPathOnVolume(c *Container, containerPath string) bool {
if cleanedContainerPath == filepath.Clean(vol.Dest) {
return true
}
for dest := vol.Dest; dest != "/"; dest = filepath.Dir(dest) {
for dest := vol.Dest; dest != "/" && dest != "."; dest = filepath.Dir(dest) {
if cleanedContainerPath == dest {
return true
}
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,17 @@ USER mail`, BB)
Expect(session.OutputToString()).To(ContainSubstring("mail root"))
})

It("podman run with incorect VOLUME", func() {
dockerfile := fmt.Sprintf(`FROM %s
VOLUME ['/etc/foo']
WORKDIR /etc/foo`, BB)
podmanTest.BuildImage(dockerfile, "test", "false")
session := podmanTest.Podman([]string{"run", "--rm", "test", "echo", "test"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(session.OutputToString()).To(ContainSubstring("test"))
})

It("podman run --volumes-from flag", func() {
vol := filepath.Join(podmanTest.TempDir, "vol-test")
err := os.MkdirAll(vol, 0755)
Expand Down

0 comments on commit 41ac68d

Please sign in to comment.