From 08e5c568d5f36423492c0f0dabfa492af4687d0f Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Mon, 11 Mar 2024 21:15:24 -0700 Subject: [PATCH] fix: zero len put error when content length value not defined Fixes #444. For some clients using chunked uploads with a zero length file, the content length value from the request headers was coming back as an empty string. If this happens, just set it to "0" so that we can successfully parse this to int value. --- s3api/controllers/base.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/s3api/controllers/base.go b/s3api/controllers/base.go index 7332c2c4..e8f8f0d3 100644 --- a/s3api/controllers/base.go +++ b/s3api/controllers/base.go @@ -909,6 +909,9 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error { // Other headers contentLengthStr := ctx.Get("Content-Length") + if contentLengthStr == "" { + contentLengthStr = "0" + } bucketOwner := ctx.Get("X-Amz-Expected-Bucket-Owner") grants := grantFullControl + grantRead + grantReadACP + granWrite + grantWriteACP