fix NULL dereference (#3347) in emv_pki_decode_message when crypto_pk_encrypt fails

This commit is contained in:
achazal committed 2026-06-02 17:10:57 +02:00
1 parent ea142febde
commit 8465ea9cba
1 file changed
+5 -4
+5 -4
View File
@@ -75,10 +75,11 @@ static unsigned char *emv_pki_decode_message(const struct emv_pk *enc_pk,
data = crypto_pk_encrypt(kcp, cert_tlv->value, cert_tlv->len, &data_len);
crypto_pk_close(kcp);
/* if (true){
PrintAndLogEx(SUCCESS, "Recovered data:\n");
print_buffer(data, data_len, 1);
}*/
if (data == NULL || data_len < 3) {
PrintAndLogEx(WARNING, "ERROR: Certificate decrypt failed");
free(data);
return NULL;
}
if (data[data_len - 1] != 0xbc || data[0] != 0x6a || data[1] != msgtype) {
PrintAndLogEx(WARNING, "ERROR: Certificate format");