Merge pull request #10238 from bacher09/fix-inf-loop

Fix infinite loop in isPathOnVolume
This commit is contained in:
OpenShift Merge Robot 2021-05-07 05:33:25 -04:00 committed by GitHub
commit 41ac68d197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -128,7 +128,7 @@ func isPathOnVolume(c *Container, containerPath string) bool {
if cleanedContainerPath == filepath.Clean(vol.Dest) { if cleanedContainerPath == filepath.Clean(vol.Dest) {
return true return true
} }
for dest := vol.Dest; dest != "/"; dest = filepath.Dir(dest) { for dest := vol.Dest; dest != "/" && dest != "."; dest = filepath.Dir(dest) {
if cleanedContainerPath == dest { if cleanedContainerPath == dest {
return true return true
} }

View File

@ -921,6 +921,17 @@ USER mail`, BB)
Expect(session.OutputToString()).To(ContainSubstring("mail root")) 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() { It("podman run --volumes-from flag", func() {
vol := filepath.Join(podmanTest.TempDir, "vol-test") vol := filepath.Join(podmanTest.TempDir, "vol-test")
err := os.MkdirAll(vol, 0755) err := os.MkdirAll(vol, 0755)