diff options
author | Zuul <zuul@review.opendev.org> | 2021-01-08 04:52:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-01-08 04:52:39 +0000 |
commit | 1cffbe5b8f0f320de0ea8c52e0b4e1963bf48154 (patch) | |
tree | 3dd7a1076dbb2bdd8b3f87ebfa3ea5b0b646c16c /swift/common/middleware/s3api/s3request.py | |
parent | 6eaddd3c38c45efe220cdab13cd649f9c6f9ba0e (diff) | |
parent | 87e88782aa14df5fe112fb0921aa9e4db74a153e (diff) | |
download | swift-1cffbe5b8f0f320de0ea8c52e0b4e1963bf48154.tar.gz |
Merge "s3api: Better-handle SHA mismatches during CompleteMultipartUpload"
Diffstat (limited to 'swift/common/middleware/s3api/s3request.py')
-rw-r--r-- | swift/common/middleware/s3api/s3request.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/swift/common/middleware/s3api/s3request.py b/swift/common/middleware/s3api/s3request.py index a722d8523..059c2b784 100644 --- a/swift/common/middleware/s3api/s3request.py +++ b/swift/common/middleware/s3api/s3request.py @@ -448,8 +448,8 @@ class SigV4Mixin(object): 'x-amz-content-sha256' raise InvalidRequest(msg) else: - hashed_payload = self.headers['X-Amz-Content-SHA256'] - if hashed_payload != 'UNSIGNED-PAYLOAD': + hashed_payload = self.headers['X-Amz-Content-SHA256'].lower() + if hashed_payload != 'unsigned-payload': if self.content_length == 0: if hashed_payload != sha256().hexdigest(): raise BadDigest( @@ -853,7 +853,15 @@ class S3Request(swob.Request): if te or ml: # Limit the read similar to how SLO handles manifests - body = self.body_file.read(max_length) + try: + body = self.body_file.read(max_length) + except swob.HTTPException as err: + if err.status_int == HTTP_UNPROCESSABLE_ENTITY: + # Special case for HashingInput check + raise BadDigest( + 'The X-Amz-Content-SHA56 you specified did not ' + 'match what we received.') + raise else: # No (or zero) Content-Length provided, and not chunked transfer; # no body. Assume zero-length, and enforce a required body below. |