diff options
author | Bodo Möller <bodo@openssl.org> | 2002-08-27 13:32:35 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2002-08-27 13:32:35 +0000 |
commit | c237de058f91072b5d54ad9c570049c14df6957e (patch) | |
tree | 0d086620122c5a5ff0f431add41deb5d14ca0b39 /crypto | |
parent | e2aeb8174bd11c3dff2861fb6e1afa4c04587b19 (diff) |
don't write beyond buffer
Submitted by: Nils Larsch
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/bn_gf2m.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 8bd17e0e7c..dea1fd3b87 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -370,12 +370,16 @@ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]) for (k = 1; p[k] > 0; k++) { + BN_ULONG tmp_ulong; + /* reducing component t^p[k]*/ n = p[k] / BN_BITS2; d0 = p[k] % BN_BITS2; d1 = BN_BITS2 - d0; z[n] ^= (zz << d0); - if (d0) z[n+1] ^= (zz >> d1); + tmp_ulong = zz >> d1; + if (d0 && tmp_ulong) + z[n+1] ^= tmp_ulong; } |