Simon Josefsson <[EMAIL PROTECTED]> writes: > Ok to install patch below?
There weren't any objections, so I take that as a "yes". Installed: > 2005-10-23 Simon Josefsson <[EMAIL PROTECTED]> > > * md5.h, md5.c: Simplify buffer handling visavi alignment, same as > recent md4 change. > > --- md5.h 12 Oct 2005 02:19:33 +0200 1.19 > +++ md5.h 24 Oct 2005 20:31:38 +0200 > @@ -70,7 +70,7 @@ > > uint32_t total[2]; > uint32_t buflen; > - char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t)))); > + uint32_t buffer[32]; > }; > > /* > --- md5.c 11 Oct 2005 20:34:49 +0200 1.21 > +++ md5.c 24 Oct 2005 20:30:05 +0200 > @@ -108,23 +108,21 @@ > { > /* Take yet unprocessed bytes into account. */ > uint32_t bytes = ctx->buflen; > - size_t pad; > + size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; > > /* Now count remaining bytes. */ > ctx->total[0] += bytes; > if (ctx->total[0] < bytes) > ++ctx->total[1]; > > - pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; > - memcpy (&ctx->buffer[bytes], fillbuf, pad); > - > /* Put the 64-bit file length in *bits* at the end of the buffer. */ > - *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); > - *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | > - (ctx->total[0] >> 29)); > + ctx->buffer[size - 2] = SWAP (ctx->total[0] << 3); > + ctx->buffer[size - 1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> > 29)); > + > + memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); > > /* Process last bytes. */ > - md5_process_block (ctx->buffer, bytes + pad + 8, ctx); > + md5_process_block (ctx->buffer, size * 4, ctx); > > return md5_read_ctx (ctx, resbuf); > } > @@ -184,7 +182,7 @@ > md5_process_block (buffer, BLOCKSIZE, &ctx); > } > > - process_partial_block:; > +process_partial_block: > > /* Process any remaining bytes. */ > if (sum > 0) > @@ -225,7 +223,7 @@ > size_t left_over = ctx->buflen; > size_t add = 128 - left_over > len ? len : 128 - left_over; > > - memcpy (&ctx->buffer[left_over], buffer, add); > + memcpy (&((char *) ctx->buffer)[left_over], buffer, add); > ctx->buflen += add; > > if (ctx->buflen > 64) > @@ -234,7 +232,8 @@ > > ctx->buflen &= 63; > /* The regions in the following copy operation cannot overlap. */ > - memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], > + memcpy (ctx->buffer, > + &((char *) ctx->buffer)[(left_over + add) & ~63], > ctx->buflen); > } > > @@ -275,13 +274,13 @@ > { > size_t left_over = ctx->buflen; > > - memcpy (&ctx->buffer[left_over], buffer, len); > + memcpy (&((char *) ctx->buffer)[left_over], buffer, len); > left_over += len; > if (left_over >= 64) > { > md5_process_block (ctx->buffer, 64, ctx); > left_over -= 64; > - memcpy (ctx->buffer, &ctx->buffer[64], left_over); > + memcpy (ctx->buffer, &ctx->buffer[16], left_over); > } > ctx->buflen = left_over; > } _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib