Skip to content

Commit b47f509

Browse files
paulusmackJunio C Hamano
authored andcommitted
Fix PPC SHA1 routine for large input buffers
The PPC SHA1 routine had an overflow which meant that it gave incorrect results for input buffers >= 512MB. This fixes it by ensuring that the update of the total length in bits is done using 64-bit arithmetic. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 476a4df commit b47f509

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ppc/sha1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)
3030
unsigned long nb;
3131
const unsigned char *p = ptr;
3232

33-
c->len += n << 3;
33+
c->len += (uint64_t) n << 3;
3434
while (n != 0) {
3535
if (c->cnt || n < 64) {
3636
nb = 64 - c->cnt;

0 commit comments

Comments
 (0)