comparison src/xs_support.c @ 792:bee1f36efc16

Fix potential aliasing issues.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Nov 2012 10:54:23 +0200
parents 91a36a4b79c6
children 6b47d9813067
comparison
equal deleted inserted replaced
791:0995fa233462 792:bee1f36efc16
420 memset(p, 0, count - 8); 420 memset(p, 0, count - 8);
421 } 421 }
422 xs_md5_bytereverse(ctx->in, 14); 422 xs_md5_bytereverse(ctx->in, 14);
423 423
424 /* Append length in bits and transform */ 424 /* Append length in bits and transform */
425 ((guint32 *) ctx->in)[14] = ctx->bits[0]; 425 memcpy(((guint32 *) ctx->in) + 14, &ctx->bits[0], sizeof(guint32));
426 ((guint32 *) ctx->in)[15] = ctx->bits[1]; 426 memcpy(((guint32 *) ctx->in) + 15, &ctx->bits[1], sizeof(guint32));
427 427
428 xs_md5_transform(ctx->buf, (guint32 *) ctx->in); 428 xs_md5_transform(ctx->buf, (guint32 *) ctx->in);
429 xs_md5_bytereverse((guint8 *) ctx->buf, 4); 429 xs_md5_bytereverse((guint8 *) ctx->buf, 4);
430 memcpy(digest, ctx->buf, 16); 430 memcpy(digest, ctx->buf, 16);
431 memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ 431 memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */