diff mbox

[libiberty] : Fix PR 54620

Message ID CAEwic4Zt6uNyQtfiL=xWcK1nkc6hYbfb1pN1Xtzatv9i-A-VRw@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Jan. 30, 2013, 5:45 p.m. UTC
Hi,

this patch fixes wrong handling of cases that bitness of size_t is
wider as 32-bit.

ChangeLog

2013-01-30  Kai Tietz  <ktietz@redhat.com>

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

Tested for x86_64-unknown-linux-gnu, i686-pc-cygwin, and
x86_64-w64-mingw32.  Ok for apply?

Regards,
Kai

Comments

Ian Lance Taylor Jan. 30, 2013, 10:50 p.m. UTC | #1
On Wed, Jan 30, 2013 at 9:45 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>
> 2013-01-30  Kai Tietz  <ktietz@redhat.com>
>
>         PR other/54620
>         * sha1.c (sha1_process_block):  Handle case that size_t is
>         a wider-integer-scalar as a 32-bit unsigned integer.

This is OK.

Thanks.

Ian
diff mbox

Patch

Index: sha1.c
===================================================================
--- sha1.c	(Revision 195578)
+++ sha1.c	(Arbeitskopie)
@@ -300,8 +300,7 @@  sha1_process_block (const void *buffer, size_t len
      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))))