From bed779239b02026556699f5d2c7c9da7dd8bb576 Mon Sep 17 00:00:00 2001 From: Baroukh Ovadia Date: Fri, 6 Aug 2021 04:10:57 +0000 Subject: [PATCH] Changes for gcs2 --- src/mod/applications/mod_http_cache/gcs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_http_cache/gcs.c b/src/mod/applications/mod_http_cache/gcs.c index d1afc2e9e0..e7c09cba04 100644 --- a/src/mod/applications/mod_http_cache/gcs.c +++ b/src/mod/applications/mod_http_cache/gcs.c @@ -70,15 +70,18 @@ void signtoken(char *token, int tokenlen,char *pkey, char *out) { BIO *b = NULL; RSA *r = NULL; unsigned int sig_len; - unsigned char *digest = SHA256((const unsigned char *) token, tokenlen, NULL); + unsigned char *md = malloc(SHA256_DIGEST_LENGTH * sizeof(char)); + unsigned char *digest = SHA256((const unsigned char *) token, tokenlen, md); b = BIO_new_mem_buf(pkey, -1); r = PEM_read_bio_RSAPrivateKey(b, NULL, NULL, NULL); BIO_set_close(b, BIO_CLOSE); BIO_free(b); sig = malloc(RSA_size(r)); - RSA_sign(NID_sha256, digest, SHA256_DIGEST_LENGTH, sig, &sig_len, r); + RSA_sign(NID_sha256, digest, sizeof(char) * SHA256_DIGEST_LENGTH, sig, &sig_len, r); switch_b64_encode(sig,(switch_size_t) sizeof(char) * sig_len,(unsigned char *) out, 343 * sizeof(char)); free(sig); + free(md); + RSA_free(r); } char *gcs_auth_request(char *content, char *url);