From 11fadf69b1eceef4cf841fd35a3a0f98ebd2ea09 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 31 Jul 2023 17:46:38 +0900 Subject: [PATCH] aws: Allocate S3_KEY_SIZE +1 instead of S3_KEY_SIZE for allocating buffer for s3 key This is because macOS's strlen complains buffer overflow due to exceeding length of allocated buffers. To prevent this issue, we need to allocate an adittional +1 length of char type of buffer. Signed-off-by: Hiroshi Hatake --- src/aws/flb_aws_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aws/flb_aws_util.c b/src/aws/flb_aws_util.c index 75efe1b0df1..533bba7eb4d 100644 --- a/src/aws/flb_aws_util.c +++ b/src/aws/flb_aws_util.c @@ -908,8 +908,8 @@ flb_sds_t flb_get_s3_key(const char *format, time_t time, const char *tag, flb_sds_destroy(tmp); tmp = NULL; - /* A string no longer than S3_KEY_SIZE is created to store the formatted timestamp. */ - key = flb_calloc(1, S3_KEY_SIZE * sizeof(char)); + /* A string no longer than S3_KEY_SIZE + 1 is created to store the formatted timestamp. */ + key = flb_calloc(1, (S3_KEY_SIZE + 1) * sizeof(char)); if (!key) { goto error; }