fix: adds validation for chunk sizes in unsigned streaming trailer upload

Fixes #1665

S3 enforces a validation rule for unsigned streaming payload trailer uploads: all chunk sizes must be greater than 8192 bytes except for the final chunk.
This fix adds a check in the unsigned chunk reader that validates chunk sizes by comparing each chunk size to the previous one.
This commit is contained in:
niksis02
2025-12-04 16:38:30 +04:00
parent aabf214841
commit dfe6abcb2e
5 changed files with 122 additions and 2 deletions

View File

@@ -180,6 +180,7 @@ const (
ErrInvalidLocationConstraint
ErrInvalidArgument
ErrMalformedTrailer
ErrInvalidChunkSize
// Non-AWS errors
ErrExistingObjectIsDirectory
@@ -804,6 +805,11 @@ var errorCodeResponse = map[ErrorCode]APIError{
Description: "The request contained trailing data that was not well-formed or did not conform to our published schema.",
HTTPStatusCode: http.StatusBadRequest,
},
ErrInvalidChunkSize: {
Code: "InvalidChunkSizeError",
Description: "Only the last chunk is allowed to have a size less than 8192 bytes",
HTTPStatusCode: http.StatusBadRequest,
},
// non aws errors
ErrExistingObjectIsDirectory: {