aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-24 10:35:12 -0400
committerGitHub <noreply@github.com>2021-06-24 10:35:12 -0400
commitf8a793a72d0b3ed52ced0e0e765935280c48c786 (patch)
tree132449013e980eea8ea003fb75a0393db7283ad8 /cmd
parent3ee967bd5da30ddbd3a8625b00bb82f903641800 (diff)
parent879d66e7db25d1bd1ce8c0906ceb069cdf713f62 (diff)
downloadpodman-f8a793a72d0b3ed52ced0e0e765935280c48c786.tar.gz
podman-f8a793a72d0b3ed52ced0e0e765935280c48c786.tar.bz2
podman-f8a793a72d0b3ed52ced0e0e765935280c48c786.zip
Merge pull request #10775 from vrothberg/3.2-fix-cp
[v3.2] cp: do not allow dir->file copying
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/cp.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index 27aacc6e5..0be135c91 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -179,6 +179,10 @@ func copyFromContainer(container string, containerPath string, hostPath string)
containerTarget = filepath.Dir(containerTarget)
}
+ if !isStdout && containerInfo.IsDir && !hostInfo.IsDir {
+ return errors.New("destination must be a directory when copying a directory")
+ }
+
reader, writer := io.Pipe()
hostCopy := func() error {
defer reader.Close()
@@ -336,6 +340,10 @@ func copyToContainer(container string, containerPath string, hostPath string) er
stdinFile = tmpFile.Name()
}
+ if hostInfo.IsDir && !containerInfo.IsDir {
+ return errors.New("destination must be a directory when copying a directory")
+ }
+
reader, writer := io.Pipe()
hostCopy := func() error {
defer writer.Close()