aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-04-19 20:26:07 +0200
committerMarvin W <git@larma.de>2017-04-19 20:31:36 +0200
commit5c8275ed4efdc7a3a0bc2a9c3a3f46d0383ddcf4 (patch)
tree82aefddbb66e0f5c8101147115411d3474a14a4d /plugins
parent7e388fb2bc784568734592dcb2e863dfa061bed4 (diff)
downloaddino-5c8275ed4efdc7a3a0bc2a9c3a3f46d0383ddcf4.tar.gz
dino-5c8275ed4efdc7a3a0bc2a9c3a3f46d0383ddcf4.zip
signal-protocol: use proper types and fix memleak (#59)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/signal-protocol/src/signal_helper.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/plugins/signal-protocol/src/signal_helper.c b/plugins/signal-protocol/src/signal_helper.c
index 5cbf2ce2..f39c4a5c 100644
--- a/plugins/signal-protocol/src/signal_helper.c
+++ b/plugins/signal-protocol/src/signal_helper.c
@@ -113,8 +113,8 @@ int signal_vala_hmac_sha256_update(void *hmac_context, const uint8_t *data, size
}
int signal_vala_hmac_sha256_final(void *hmac_context, signal_buffer **output, void *user_data) {
- unsigned int len = gcry_mac_get_algo_maclen(GCRY_MAC_HMAC_SHA256);
- unsigned char md[len];
+ size_t len = gcry_mac_get_algo_maclen(GCRY_MAC_HMAC_SHA256);
+ uint8_t md[len];
gcry_mac_hd_t* ctx = hmac_context;
if (gcry_mac_read(*ctx, md, &len)) return SG_ERR_UNKNOWN;
@@ -158,15 +158,16 @@ int signal_vala_sha512_digest_update(void *digest_context, const uint8_t *data,
}
int signal_vala_sha512_digest_final(void *digest_context, signal_buffer **output, void *user_data) {
- unsigned int len = gcry_md_get_algo_dlen(GCRY_MD_SHA512);
+ size_t len = gcry_md_get_algo_dlen(GCRY_MD_SHA512);
gcry_md_hd_t* ctx = digest_context;
- unsigned char* md = gcry_md_read(*ctx, GCRY_MD_SHA512);
+ uint8_t* md = gcry_md_read(*ctx, GCRY_MD_SHA512);
if (!md) return SG_ERR_UNKNOWN;
gcry_md_reset(*ctx);
signal_buffer *output_buffer = signal_buffer_create(md, len);
+ free(md);
if (!output_buffer) return SG_ERR_NOMEM;
*output = output_buffer;