From: Bodo Möller Date: Tue, 27 Aug 2002 13:32:35 +0000 (+0000) Subject: don't write beyond buffer X-Git-Tag: OpenSSL_0_9_7-beta4~168^2~16 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c237de058f91072b5d54ad9c570049c14df6957e;p=oweals%2Fopenssl.git don't write beyond buffer Submitted by: Nils Larsch --- 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; }