diff options
Diffstat (limited to 'md5')
-rw-r--r-- | md5/md5.c | 5 | ||||
-rw-r--r-- | md5/media-thumb-hash.c | 2 |
2 files changed, 4 insertions, 3 deletions
@@ -143,13 +143,12 @@ void MD5Final(unsigned char digest[16], MD5_CTX *ctx) byteReverse(ctx->in, 14); /* Append length in bits and transform */ - ((uint32_t *) ctx->in)[14] = ctx->bits[0]; - ((uint32_t *) ctx->in)[15] = ctx->bits[1]; + memcpy(((uint32_t *) ctx->in)+14, ctx->bits, sizeof(uint32_t)*2); MD5Transform(ctx->buf, (uint32_t *) ctx->in); byteReverse((unsigned char *)ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset((char *)ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset((char *)ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ diff --git a/md5/media-thumb-hash.c b/md5/media-thumb-hash.c index aed15b0..5e1ffb1 100644 --- a/md5/media-thumb-hash.c +++ b/md5/media-thumb-hash.c @@ -91,6 +91,8 @@ char *_media_thumb_generate_hash_name(const char *file) *t = '\0'; #undef _check_uri_char + memset(&ctx, 0x00, sizeof(MD5_CTX)); + MD5Init(&ctx); MD5Update(&ctx, (unsigned char const *)uri, (unsigned)strlen(uri)); MD5Final(hash, &ctx); |