Skip to content

Commit ad6b5de

Browse files
cosmo0920edsiper
authored andcommitted
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 <[email protected]>
1 parent ed13084 commit ad6b5de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/aws/flb_aws_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ flb_sds_t flb_get_s3_key(const char *format, time_t time, const char *tag,
908908
flb_sds_destroy(tmp);
909909
tmp = NULL;
910910

911-
/* A string no longer than S3_KEY_SIZE is created to store the formatted timestamp. */
912-
key = flb_calloc(1, S3_KEY_SIZE * sizeof(char));
911+
/* A string no longer than S3_KEY_SIZE + 1 is created to store the formatted timestamp. */
912+
key = flb_calloc(1, (S3_KEY_SIZE + 1) * sizeof(char));
913913
if (!key) {
914914
goto error;
915915
}

0 commit comments

Comments
 (0)