Skip to content

Commit 11bd79e

Browse files
ravulapxYogaraj-Alamenda
authored andcommitted
Fix possible NULL pointer dereference for SM4-CCM
Added a check to ensure p->data is not NULL before calling memcpy in qat_sm4_ccm_set_ctx_params function. This prevents a possible null pointer dereference when setting CCM parameters. Signed-off-by: Vemula, RaveeshX <[email protected]> Co-authored-by: Tirupatigopi Ravulapalli <[email protected]>
1 parent 990e464 commit 11bd79e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

qat_prov_sm4_ccm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,11 @@ int qat_sm4_ccm_set_ctx_params(void *vctx, const OSSL_PARAM params[])
367367
ctx->M = p->data_size;
368368
if (ctx->sw_ctx != NULL) {
369369
PROV_CCM_CTX *sctx = (PROV_CCM_CTX *) ctx->sw_ctx;
370-
memcpy(sctx->buf, p->data, p->data_size);
371370
sctx->m = p->data_size;
372-
sctx->tag_set = 1;
371+
if (p->data != NULL) {
372+
memcpy(sctx->buf, p->data, p->data_size);
373+
sctx->tag_set = 1;
374+
}
373375
}
374376
}
375377

0 commit comments

Comments
 (0)