Skip to content

Commit 6d774dd

Browse files
authored
[core] Fixed invalid ASSERT checking outdated object in haicrypt (#2652).
1 parent a7bd1b0 commit 6d774dd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

haicrypt/hcrypt_tx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,25 @@ int HaiCrypt_Tx_GetBuf(HaiCrypt_Handle hhc, size_t data_len, unsigned char **in_
5555
int HaiCrypt_Tx_ManageKeys(HaiCrypt_Handle hhc, void *out_p[], size_t out_len_p[], int maxout)
5656
{
5757
hcrypt_Session *crypto = (hcrypt_Session *)hhc;
58-
hcrypt_Ctx *ctx = NULL;
5958
int nbout = 0;
6059

6160
if ((NULL == crypto)
62-
|| (NULL == (ctx = crypto->ctx))
61+
|| (NULL == crypto->ctx)
6362
|| (NULL == out_p)
6463
|| (NULL == out_len_p)) {
65-
HCRYPT_LOG(LOG_ERR, "ManageKeys: invalid params: crypto=%p crypto->ctx=%p\n", crypto, ctx);
64+
HCRYPT_LOG(LOG_ERR, "ManageKeys: invalid params: crypto=%p out_p=%p out_len_p=%p\n",
65+
crypto, out_p, out_len_p);
6666
return(-1);
6767
}
6868

6969
/* Manage Key Material (refresh, announce, decommission) */
7070
hcryptCtx_Tx_ManageKM(crypto);
7171

72-
ASSERT(ctx->status == HCRYPT_CTX_S_ACTIVE);
72+
if (NULL == crypto->ctx) {
73+
HCRYPT_LOG(LOG_ERR, "%s", "crypto context NULL after ManageKM call\n");
74+
return(-1);
75+
}
76+
ASSERT(crypto->ctx->status == HCRYPT_CTX_S_ACTIVE);
7377

7478
nbout = hcryptCtx_Tx_InjectKM(crypto, out_p, out_len_p, maxout);
7579
return(nbout);

0 commit comments

Comments
 (0)