summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/http_aws_sigv4.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/http_aws_sigv4.c')
-rw-r--r--Utilities/cmcurl/lib/http_aws_sigv4.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Utilities/cmcurl/lib/http_aws_sigv4.c b/Utilities/cmcurl/lib/http_aws_sigv4.c
index f39d02c..901c22f 100644
--- a/Utilities/cmcurl/lib/http_aws_sigv4.c
+++ b/Utilities/cmcurl/lib/http_aws_sigv4.c
@@ -34,6 +34,7 @@
#include "transfer.h"
#include "parsedate.h"
#include "sendf.h"
+#include "escape.h"
#include <time.h>
@@ -63,11 +64,8 @@
static void sha256_to_hex(char *dst, unsigned char *sha)
{
- int i;
-
- for(i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
- msnprintf(dst + (i * 2), SHA256_HEX_LENGTH - (i * 2), "%02x", sha[i]);
- }
+ Curl_hexencode(sha, SHA256_DIGEST_LENGTH,
+ (unsigned char *)dst, SHA256_HEX_LENGTH);
}
static char *find_date_hdr(struct Curl_easy *data, const char *sig_hdr)
@@ -409,6 +407,11 @@ static int compare_func(const void *a, const void *b)
{
const struct pair *aa = a;
const struct pair *bb = b;
+ /* If one element is empty, the other is always sorted higher */
+ if(aa->len == 0)
+ return -1;
+ if(bb->len == 0)
+ return 1;
return strncmp(aa->p, bb->p, aa->len < bb->len ? aa->len : bb->len);
}