]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - crypto/bn/bn_mont.c
Fix a possible crash in BN_from_montgomery_word
[thirdparty/openssl.git] / crypto / bn / bn_mont.c
index c882891d5e2ef9136d8ed3d690fd0fccbfcb30e6..362390a353286aeb2389fbb872fe0e8e9fb2db01 100644 (file)
@@ -95,6 +95,8 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
 
     /* clear the top words of T */
     i = max - r->top;
+    if (i < 0)
+        return 0;
     if (i)
         memset(&rp[r->top], 0, sizeof(*rp) * i);