Commit c8a9fa69 authored by Shane Lontis's avatar Shane Lontis Committed by Richard Levitte
Browse files

Added NULL check to BN_clear() & BN_CTX_end()



Reviewed-by: default avatarPaul Dale <paul.dale@oracle.com>
Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8518)

(cherry picked from commit ce1415ed)
parent 202f7c56
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -194,6 +194,8 @@ void BN_CTX_start(BN_CTX *ctx)

void BN_CTX_end(BN_CTX *ctx)
{
    if (ctx == NULL)
        return;
    CTXDBG_ENTRY("BN_CTX_end", ctx);
    if (ctx->err_stack)
        ctx->err_stack--;
+2 −0
Original line number Diff line number Diff line
@@ -338,6 +338,8 @@ void BN_swap(BIGNUM *a, BIGNUM *b)

void BN_clear(BIGNUM *a)
{
    if (a == NULL)
        return;
    bn_check_top(a);
    if (a->d != NULL)
        OPENSSL_cleanse(a->d, sizeof(*a->d) * a->dmax);
+1 −2
Original line number Diff line number Diff line
@@ -135,7 +135,6 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
    found = 1;
 err:
    OPENSSL_free(mods);
    if (ctx != NULL)
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);
    bn_check_top(ret);
+6 −12
Original line number Diff line number Diff line
@@ -58,10 +58,8 @@ int DH_check_params(const DH *dh, int *ret)

    ok = 1;
 err:
    if (ctx != NULL) {
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);
    }
    return ok;
}

@@ -171,10 +169,8 @@ int DH_check(const DH *dh, int *ret)
    }
    ok = 1;
 err:
    if (ctx != NULL) {
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);
    }
    return ok;
}

@@ -225,9 +221,7 @@ int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)

    ok = 1;
 err:
    if (ctx != NULL) {
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);
    }
    return ok;
}
+2 −4
Original line number Diff line number Diff line
@@ -122,9 +122,7 @@ static int dh_builtin_genparams(DH *ret, int prime_len, int generator,
        ok = 0;
    }

    if (ctx != NULL) {
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);
    }
    return ok;
}
Loading