Apply security patch (revision:245e106aacc48e38784d1efe71df4e4f7a2643ab)
[platform/core/multimedia/libmedia-service.git] / md5 / md5.c
index 3782384..980e11c 100755 (executable)
--- a/md5/md5.c
+++ b/md5/md5.c
@@ -46,7 +46,7 @@ void byteReverse(unsigned char *buf, unsigned longs)
  * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
  * initialization constants.
  */
-void MD5Init(MD5_CTX *ctx)
+void media_svc_MD5Init(MD5_CTX *ctx)
 {
        ctx->buf[0] = 0x67452301;
        ctx->buf[1] = 0xefcdab89;
@@ -61,7 +61,7 @@ void MD5Init(MD5_CTX *ctx)
  * Update context to reflect the concatenation of another buffer full
  * of bytes.
  */
-void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
+void media_svc_MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
 {
        uint32_t t;
 
@@ -111,7 +111,7 @@ void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
  * Final wrapup - pad to 64-byte boundary with the bit pattern
  * 1 0* (64-bit count of bits processed, MSB-first)
  */
-void MD5Final(unsigned char digest[16], MD5_CTX *ctx)
+void media_svc_MD5Final(unsigned char digest[16], MD5_CTX *ctx)
 {
        unsigned count;
        unsigned char *p;
@@ -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 */