summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2019-06-08 09:07:04 +1000
committerDarren Tucker <dtucker@dtucker.net>2019-06-14 14:22:39 +1000
commitadcaf40fd0a180e6cb5798317fdf479b52e3c09a (patch)
tree8397465cd83462c7c8dd78e1d6796734052ef3ea
parent7689048e6103d3c34cba24ac5aeea7bf8405d19a (diff)
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@
-rw-r--r--openbsd-compat/sha1.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/openbsd-compat/sha1.c b/openbsd-compat/sha1.c
index 2089ec34..73f89748 100644
--- a/openbsd-compat/sha1.c
+++ b/openbsd-compat/sha1.c
@@ -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);