Skip to content

Commit

Permalink
aws: Allocate S3_KEY_SIZE +1 instead of S3_KEY_SIZE for allocating bu…
Browse files Browse the repository at this point in the history
…ffer 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]>
  • Loading branch information
cosmo0920 committed Jul 31, 2023
1 parent 1d83649 commit 11fadf6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/aws/flb_aws_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 11fadf6

Please sign in to comment.