From 2a49b4351d828f3ff79fdc98e0eceedf90dca3d6 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 15 Nov 2023 13:40:39 +0800 Subject: [PATCH] cos/multipart: limit max part to 1k --- source/common/src/cos.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/common/src/cos.c b/source/common/src/cos.c index 0dbe9c1286..db95fb02bb 100644 --- a/source/common/src/cos.c +++ b/source/common/src/cos.c @@ -513,9 +513,14 @@ int32_t s3PutObjectFromFile2(const char *file, const char *object) { manager.gb = 0; // div round up - int seq; - uint64_t chunk_size = MULTIPART_CHUNK_SIZE >> 7; - int totalSeq = ((contentLength + chunk_size - 1) / chunk_size); + int seq; + uint64_t chunk_size = MULTIPART_CHUNK_SIZE >> 7; + int totalSeq = (contentLength + chunk_size - 1) / chunk_size; + const int max_part_num = 1000; + if (totalSeq > max_part_num) { + chunk_size = (contentLength + max_part_num - contentLength % max_part_num) / max_part_num; + totalSeq = (contentLength + chunk_size - 1) / chunk_size; + } MultipartPartData partData; memset(&partData, 0, sizeof(MultipartPartData));