From 3b44afab33a9c112be572ec57601e4698f5f2273 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Wed, 8 Mar 2023 08:19:06 -0800 Subject: [PATCH] aws: fix some possible leaks Signed-off-by: David Korczynski --- src/aws/flb_aws_credentials_http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/aws/flb_aws_credentials_http.c b/src/aws/flb_aws_credentials_http.c index 577b156f6c6..a9c0a2af832 100644 --- a/src/aws/flb_aws_credentials_http.c +++ b/src/aws/flb_aws_credentials_http.c @@ -473,6 +473,10 @@ struct flb_aws_credentials *flb_parse_json_credentials(char *response, t = &tokens[i]; current_token = &response[t->start]; len = t->end - t->start; + if (creds->access_key_id != NULL) { + flb_error("Triyng to double allocate access_key_id"); + goto error; + } creds->access_key_id = flb_sds_create_len(current_token, len); if (!creds->access_key_id) { flb_errno(); @@ -486,6 +490,10 @@ struct flb_aws_credentials *flb_parse_json_credentials(char *response, t = &tokens[i]; current_token = &response[t->start]; len = t->end - t->start; + if (creds->secret_access_key != NULL) { + flb_error("Triyng to double allocate secret_access_key"); + goto error; + } creds->secret_access_key = flb_sds_create_len(current_token, len); if (!creds->secret_access_key) { @@ -499,6 +507,10 @@ struct flb_aws_credentials *flb_parse_json_credentials(char *response, t = &tokens[i]; current_token = &response[t->start]; len = t->end - t->start; + if (creds->session_token != NULL) { + flb_error("Triyng to double allocate session_token"); + goto error; + } creds->session_token = flb_sds_create_len(current_token, len); if (!creds->session_token) { flb_errno();