mirror of git://anongit.mindrot.org/openssh.git
upstream rev 1.27: fix integer overflow.
Cast bitcount to u_in64_t before bit shifting to prevent integer overflow on 32bit platforms which cause incorrect results when adding a block >=512M in size. sha1 patch from ante84 at gmail.com via openssh github, sha2 with djm@, ok tedu@
This commit is contained in:
parent
7689048e61
commit
adcaf40fd0
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sha1.c,v 1.26 2015/09/11 09:18:27 guenther Exp $ */
|
||||
/* $OpenBSD: sha1.c,v 1.27 2019/06/07 22:56:36 dtucker Exp $ */
|
||||
|
||||
/*
|
||||
* SHA-1 in C
|
||||
|
@ -131,7 +131,7 @@ SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
|
|||
size_t i, j;
|
||||
|
||||
j = (size_t)((context->count >> 3) & 63);
|
||||
context->count += (len << 3);
|
||||
context->count += ((u_int64_t)len << 3);
|
||||
if ((j + len) > 63) {
|
||||
(void)memcpy(&context->buffer[j], data, (i = 64-j));
|
||||
SHA1Transform(context->state, context->buffer);
|
||||
|
|
Loading…
Reference in New Issue