Browse Source

detect invalid bucket name

fix https://github.com/seaweedfs/seaweedfs/issues/4143
pull/4192/head
chrislu 2 years ago
parent
commit
1c2364936a
  1. 9
      weed/s3api/s3api_bucket_handlers.go

9
weed/s3api/s3api_bucket_handlers.go

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3bucket"
"github.com/seaweedfs/seaweedfs/weed/util"
"math"
"net/http"
@ -84,6 +85,14 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
bucket, _ := s3_constants.GetBucketAndObject(r)
glog.V(3).Infof("PutBucketHandler %s", bucket)
// validate the bucket name
err := s3bucket.VerifyS3BucketName(bucket)
if err != nil {
glog.Errorf("put invalid bucket name: %v %v", bucket, err)
s3err.WriteErrorResponse(w, r, s3err.ErrInvalidBucketName)
return
}
// avoid duplicated buckets
errCode := s3err.ErrNone
if err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {

Loading…
Cancel
Save