From ceb5df542360fcac8bf3d40f620d5ca5cf555d96 Mon Sep 17 00:00:00 2001 From: ajishna <43221011+ajishna@users.noreply.github.com> Date: Fri, 9 Nov 2018 09:24:23 -0700 Subject: [PATCH 1/3] const correctness across .c and .h files --- src/include/concatkdf_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/concatkdf_int.h b/src/include/concatkdf_int.h index fe147f9..aaffbfd 100644 --- a/src/include/concatkdf_int.h +++ b/src/include/concatkdf_int.h @@ -14,7 +14,7 @@ #include bool cjose_concatkdf_create_otherinfo(const char *alg, - size_t keylen, + const size_t keylen, cjose_header_t *hdr, uint8_t **otherinfo, size_t *otherinfoLen, cjose_err *err); From b3dc6a766c70e517829c3be74a6f3c7f36d170ca Mon Sep 17 00:00:00 2001 From: ajishna <43221011+ajishna@users.noreply.github.com> Date: Fri, 9 Nov 2018 09:27:16 -0700 Subject: [PATCH 2/3] Use cjose dealloc fn instead of free() --- src/jws.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jws.c b/src/jws.c index 4e03554..88038e4 100644 --- a/src/jws.c +++ b/src/jws.c @@ -59,10 +59,10 @@ static bool _cjose_jws_build_hdr(cjose_jws_t *jws, cjose_header_t *header, cjose } if (!cjose_base64url_encode((const uint8_t *)hdr_str, strlen(hdr_str), &jws->hdr_b64u, &jws->hdr_b64u_len, err)) { - free(hdr_str); + cjose_get_dealloc()(hdr_str); return false; } - free(hdr_str); + cjose_get_dealloc()(hdr_str); return true; } From eed819fe99603271e22e4faefab2429e7aa9b2b1 Mon Sep 17 00:00:00 2001 From: ajishna <43221011+ajishna@users.noreply.github.com> Date: Fri, 9 Nov 2018 09:28:42 -0700 Subject: [PATCH 3/3] const correctness across .c and .h files --- src/base64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/base64.c b/src/base64.c index 9a33ebd..c33057a 100644 --- a/src/base64.c +++ b/src/base64.c @@ -229,20 +229,20 @@ static inline bool _encode(const uint8_t *input, size_t inlen, char **output, si // interface functions -bool cjose_base64_encode(const uint8_t *input, size_t inlen, char **output, size_t *outlen, cjose_err *err) +bool cjose_base64_encode(const uint8_t *input, const size_t inlen, char **output, size_t *outlen, cjose_err *err) { return _encode(input, inlen, output, outlen, ALPHABET_B64, err); } -bool cjose_base64url_encode(const uint8_t *input, size_t inlen, char **output, size_t *outlen, cjose_err *err) +bool cjose_base64url_encode(const uint8_t *input, const size_t inlen, char **output, size_t *outlen, cjose_err *err) { return _encode(input, inlen, output, outlen, ALPHABET_B64U, err); } -bool cjose_base64_decode(const char *input, size_t inlen, uint8_t **output, size_t *outlen, cjose_err *err) +bool cjose_base64_decode(const char *input, const size_t inlen, uint8_t **output, size_t *outlen, cjose_err *err) { return _decode(input, inlen, output, outlen, false, err); } -bool cjose_base64url_decode(const char *input, size_t inlen, uint8_t **output, size_t *outlen, cjose_err *err) +bool cjose_base64url_decode(const char *input, const size_t inlen, uint8_t **output, size_t *outlen, cjose_err *err) { return _decode(input, inlen, output, outlen, true, err); }