Commit 2392eb77 authored by Bernd Edlinger's avatar Bernd Edlinger Committed by Dr. Matthias St. Pierre
Browse files

Fix a possible crash in BN_from_montgomery_word



Thanks to Darovskikh Andrei for for reporting this issue.

Fixes: #5785
Fixes: #6302

Cherry-picked from f91e026e (without test/bntest.c)

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarMatthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6310)
parent 4e079413
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);