fix: avoid URL unsafe chars in multipart upload ID (#16034)

This commit is contained in:
Aditya Manthramurthy 2022-11-09 16:41:16 -08:00 committed by GitHub
parent 40a2c6b882
commit 5f1999cc71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View file

@ -43,7 +43,7 @@ import (
func (er erasureObjects) getUploadIDDir(bucket, object, uploadID string) string {
uploadUUID := uploadID
uploadBytes, err := base64.StdEncoding.DecodeString(uploadID)
uploadBytes, err := base64.RawURLEncoding.DecodeString(uploadID)
if err == nil {
slc := strings.SplitN(string(uploadBytes), ".", 2)
if len(slc) == 2 {
@ -432,7 +432,7 @@ func (er erasureObjects) newMultipartUpload(ctx context.Context, bucket string,
partsMetadata[index].Metadata = userDefined
}
uploadUUID := mustGetUUID()
uploadID := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s.%s", globalDeploymentID, uploadUUID)))
uploadID := base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s.%s", globalDeploymentID, uploadUUID)))
uploadIDPath := er.getUploadIDDir(bucket, object, uploadUUID)
// Write updated `xl.meta` to all disks.

View file

@ -109,7 +109,7 @@ func checkListMultipartArgs(ctx context.Context, bucket, prefix, keyMarker, uplo
KeyMarker: keyMarker,
}
}
_, err := base64.StdEncoding.DecodeString(uploadIDMarker)
_, err := base64.RawURLEncoding.DecodeString(uploadIDMarker)
if err != nil {
logger.LogIf(ctx, err)
return MalformedUploadID{

View file

@ -1051,9 +1051,10 @@ func testListMultipartUploads(obj ObjectLayer, instanceType string, t TestErrHan
fmt.Errorf("Invalid combination of uploadID marker '%s' and marker '%s'", "abc", "asia/europe/"), false,
},
{
bucketNames[0], "asia", "asia/europe", "abc", "", 0,
// Contains a base64 padding character
bucketNames[0], "asia", "asia/europe", "abc=", "", 0,
ListMultipartsInfo{},
fmt.Errorf("Malformed upload id %s", "abc"), false,
fmt.Errorf("Malformed upload id %s", "abc="), false,
},
// Setting up valid case of ListMultiPartUploads.