aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-01-18 12:04:40 -0800
committerchrislu <chris.lu@gmail.com>2022-01-18 12:04:40 -0800
commit77362700e16c45097fe6f1411d2d70e8ef82a42a (patch)
tree40c339c56cc1d6a2c9309992208b1ac04e896ae7
parent05c3c3f56bd6810233e4344b106c4ff3fba466ad (diff)
downloadseaweedfs-77362700e16c45097fe6f1411d2d70e8ef82a42a.tar.xz
seaweedfs-77362700e16c45097fe6f1411d2d70e8ef82a42a.zip
S3: fail fast when "X-Amz-Copy-Source" is a folder
fix #2593
-rw-r--r--weed/s3api/s3api_object_copy_handlers.go9
1 files changed, 2 insertions, 7 deletions
diff --git a/weed/s3api/s3api_object_copy_handlers.go b/weed/s3api/s3api_object_copy_handlers.go
index 5c082eeda..f62db9c31 100644
--- a/weed/s3api/s3api_object_copy_handlers.go
+++ b/weed/s3api/s3api_object_copy_handlers.go
@@ -34,11 +34,7 @@ func (s3a *S3ApiServer) CopyObjectHandler(w http.ResponseWriter, r *http.Request
fullPath := util.FullPath(fmt.Sprintf("%s/%s%s", s3a.option.BucketsPath, dstBucket, dstObject))
dir, name := fullPath.DirAndName()
entry, err := s3a.getEntry(dir, name)
- if err != nil {
- s3err.WriteErrorResponse(w, r, s3err.ErrInvalidCopySource)
- return
- }
- if entry.IsDirectory {
+ if err != nil || entry.IsDirectory {
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidCopySource)
return
}
@@ -62,8 +58,7 @@ func (s3a *S3ApiServer) CopyObjectHandler(w http.ResponseWriter, r *http.Request
}
srcPath := util.FullPath(fmt.Sprintf("%s/%s%s", s3a.option.BucketsPath, srcBucket, srcObject))
dir, name := srcPath.DirAndName()
- _, err = s3a.getEntry(dir, name)
- if err != nil {
+ if entry, err := s3a.getEntry(dir, name); err != nil || entry.IsDirectory {
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidCopySource)
return
}