diff options
author | Abhinav Singh <theawless@gmail.com> | 2021-10-12 15:32:27 +0530 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-10-15 08:46:23 +0200 |
commit | 8c6f126279f8abddf76661d0b404162c15bcc2c2 (patch) | |
tree | 5ae50a767c175c616570203d59108b325af8cc5f /lib | |
parent | 7759552b80c1b818454f8888b81eee23846294c9 (diff) | |
download | curl-8c6f126279f8abddf76661d0b404162c15bcc2c2.tar.gz |
aws-sigv4: make signature work when post data is binary
User sets the post fields size for binary data. Hence, we should not be
using strlen on it.
Added test 1937 and 1938 to verify.
Closes #7844
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http_aws_sigv4.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/http_aws_sigv4.c b/lib/http_aws_sigv4.c index 8b87e1f08..cbbecb712 100644 --- a/lib/http_aws_sigv4.c +++ b/lib/http_aws_sigv4.c @@ -92,6 +92,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy) char *signed_headers = NULL; Curl_HttpReq httpreq; const char *method; + size_t post_data_len; const char *post_data = data->set.postfields ? data->set.postfields : ""; unsigned char sha_hash[32]; char sha_hex[65]; @@ -281,8 +282,12 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy) goto fail; } + if(data->set.postfieldsize < 0) + post_data_len = strlen(post_data); + else + post_data_len = (size_t)data->set.postfieldsize; Curl_sha256it(sha_hash, - (const unsigned char *) post_data, strlen(post_data)); + (const unsigned char *) post_data, post_data_len); sha256_to_hex(sha_hex, sha_hash, sizeof(sha_hex)); Curl_http_method(data, conn, &method, &httpreq); |