]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP2: Explicitly check EC_KEY before dereferencing it
authorDisha Das <dishad@codeaurora.org>
Tue, 27 Oct 2020 07:39:31 +0000 (13:09 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 27 Oct 2020 09:33:15 +0000 (11:33 +0200)
In theory, the EVP_PKEY_get0_EC_KEY() could fail, so verify that it
succeeds before using the pointer to get the group.

Fixes: 65e94351dc4a ("DPP2: Reconfig Authentication Request processing and Response generation")
Signed-off-by: Disha Das <dishad@codeaurora.org>
src/common/dpp_crypto.c

index 7c48015319d84308af5c6bbbf96f5cead3d62a2f..37c2b692bf59b2ea6c20d6208f7edc172ae1c718 100644 (file)
@@ -2305,13 +2305,15 @@ int dpp_reconfig_derive_ke_responder(struct dpp_authentication *auth,
        /* M = { cR + pR } * CI */
        cR = EVP_PKEY_get0_EC_KEY(own_key);
        pR = EVP_PKEY_get0_EC_KEY(auth->own_protocol_key);
+       if (!pR)
+               goto fail;
        group = EC_KEY_get0_group(pR);
        bnctx = BN_CTX_new();
        sum = BN_new();
        mx = BN_new();
        q = BN_new();
        m = EC_POINT_new(group);
-       if (!cR || !pR || !bnctx || !sum || !mx || !q || !m)
+       if (!cR || !bnctx || !sum || !mx || !q || !m)
                goto fail;
        cR_bn = EC_KEY_get0_private_key(cR);
        pR_bn = EC_KEY_get0_private_key(pR);