summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorBrent Cook <bcook@cvs.openbsd.org>2016-08-31 13:26:36 +0000
committerBrent Cook <bcook@cvs.openbsd.org>2016-08-31 13:26:36 +0000
commit206442f3667b983ecb487c181dd20ab79ee3c9b7 (patch)
tree7bea7903b1243a81bd2d0c1b36144dea224d9fd9 /lib/libcrypto
parent9bb2e22fc27997c5d885cac8126201d0d15b93bd (diff)
Avoid undefined-behavior right-shifting by a word-size # of bits.
Found with STACK, originally from OpenSSL, ok @beck
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/bn/bn_gf2m.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libcrypto/bn/bn_gf2m.c b/lib/libcrypto/bn/bn_gf2m.c
index d83ae291ec9..6b259f1a7e4 100644
--- a/lib/libcrypto/bn/bn_gf2m.c
+++ b/lib/libcrypto/bn/bn_gf2m.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bn_gf2m.c,v 1.21 2016/03/12 21:44:11 bcook Exp $ */
+/* $OpenBSD: bn_gf2m.c,v 1.22 2016/08/31 13:26:35 bcook Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
@@ -443,8 +443,7 @@ BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[])
d0 = p[k] % BN_BITS2;
d1 = BN_BITS2 - d0;
z[n] ^= (zz << d0);
- tmp_ulong = zz >> d1;
- if (d0 && tmp_ulong)
+ if (d0 && (tmp_ulong = zz >> d1))
z[n + 1] ^= tmp_ulong;
}