Skip to content

a code scanner reports "tbuf" resource leak in qat_prov_rsa_enc_dec.c in qat_prov_rsa_decrypt() #348

@nefigtut

Description

@nefigtut

hi, openscanhub code security scanner reports a resource leak in the qat_prov_rsa_enc_dec.c file in qat_prov_rsa_decrypt():

Defect type: RESOURCE_LEAK
QAT_Engine-1.9.0/qat_prov_rsa_enc_dec.c:608:17: leaked_storage: Variable "tbuf" going out of scope leaks the storage it points to.

Indeed, tbuf = OPENSSL_malloc(len) is allocated in qat_prov_rsa_decrypt(). Later an error check and an exit is made without freeing the allocated tbuf: if (!fun) return 0;.

I guess tbuf should be freed here as in other error paths (OPENSSL_free(tbuf);). Or (better, I guess), the tbuf = OPENSSL_malloc(len) allocation should be moved INSIDE the if (qat_hw_rsa_offload || qat_sw_rsa_offload) true branch where it is actually used, and is not used in the false branch.

Could you please have a look and probably fix? Thank you!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions