mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
libmd5sum: use tuxbox upstream code
This commit is contained in:
@@ -96,8 +96,8 @@ md5_finish_ctx (ctx, resbuf)
|
|||||||
{
|
{
|
||||||
/* Take yet unprocessed bytes into account. */
|
/* Take yet unprocessed bytes into account. */
|
||||||
md5_uint32 bytes = ctx->buflen;
|
md5_uint32 bytes = ctx->buflen;
|
||||||
|
md5_uint32 swap_bytes;
|
||||||
size_t pad;
|
size_t pad;
|
||||||
md5_uint32 *p;
|
|
||||||
|
|
||||||
/* Now count remaining bytes. */
|
/* Now count remaining bytes. */
|
||||||
ctx->total[0] += bytes;
|
ctx->total[0] += bytes;
|
||||||
@@ -107,11 +107,13 @@ md5_finish_ctx (ctx, resbuf)
|
|||||||
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
|
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
|
||||||
memmove (&ctx->buffer[bytes], fillbuf, pad);
|
memmove (&ctx->buffer[bytes], fillbuf, pad);
|
||||||
|
|
||||||
/* Put the 64-bit file length in *bits* at the end of the buffer. */
|
/* Put the 64-bit file length in *bits* at the end of the buffer.
|
||||||
p = (md5_uint32 *)&ctx->buffer[bytes + pad];
|
Use memcpy to avoid aliasing problems. On most systems, this
|
||||||
*p = SWAP (ctx->total[0] << 3);
|
will be optimized away to the same code. */
|
||||||
p++;
|
swap_bytes = SWAP (ctx->total[0] << 3);
|
||||||
*p = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
|
memcpy (&ctx->buffer[bytes + pad], &swap_bytes, sizeof (swap_bytes));
|
||||||
|
swap_bytes = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
|
||||||
|
memcpy (&ctx->buffer[bytes + pad + 4], &swap_bytes, sizeof (swap_bytes));
|
||||||
|
|
||||||
/* Process last bytes. */
|
/* Process last bytes. */
|
||||||
md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
|
md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
|
||||||
|
Reference in New Issue
Block a user