backport: re PR other/54620 (sha1.c has incorrect math if sizeof(size_t) is 8)

Merged from trunk
	PR other/54620
	* sha1.c (sha1_process_block):  Handle case that size_t is
	a wider-integer-scalar as a 32-bit unsigned integer.

From-SVN: r195605
This commit is contained in:
Kai Tietz 2013-01-31 09:19:03 +01:00 committed by Kai Tietz
parent 27071671e0
commit 3fbaeb155d
2 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,10 @@
2013-01-31 Kai Tietz <ktietz@redhat.com>
Merged from trunk
PR other/54620
* sha1.c (sha1_process_block): Handle case that size_t is
a wider-integer-scalar as a 32-bit unsigned integer.
Merged from trunk.
PR other/543413
* md5.c (md5_process_block): Handle case that size_t is

View File

@ -300,8 +300,7 @@ sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
length of the file up to 2^64 bits. Here we only compute the
number of bytes. Do a double word increment. */
ctx->total[0] += len;
if (ctx->total[0] < len)
++ctx->total[1];
ctx->total[1] += ((len >> 31) >> 1) + (ctx->total[0] < len);
#define rol(x, n) (((x) << (n)) | ((sha1_uint32) (x) >> (32 - (n))))