cppcheck Passing NULL after the last typed argument to a variadic function leads to undefined behaviour

This commit is contained in:
Philippe Teuwen committed 2021-09-04 00:54:59 +02:00
1 parent 58a963d41f
commit 8772edb6b8
3 files changed
+10 -20

No files matched your search

+5 -10
View File
@@ -190,8 +190,7 @@ static struct emv_pk *emv_pki_decode_key_ex(const struct emv_pk *enc_pk,
rem_tlv,
exp_tlv,
add_tlv,
sdatl_tlv,
NULL);
sdatl_tlv);
if (!data || data_len < 11 + pan_length) {
PrintAndLogEx(WARNING, "ERROR: Can't decode message");
return NULL;
@@ -364,8 +363,7 @@ struct tlvdb *emv_pki_recover_dac_ex(const struct emv_pk *enc_pk, const struct t
tlvdb_get(db, 0x93, NULL),
3,
sda_tlv,
&sda_tdata,
NULL);
&sda_tdata);
free(sdatl); // malloc here: emv_pki_sdatl_fill
@@ -395,8 +393,7 @@ struct tlvdb *emv_pki_recover_idn_ex(const struct emv_pk *enc_pk, const struct t
unsigned char *data = emv_pki_decode_message(enc_pk, 5, &data_len,
tlvdb_get(db, 0x9f4b, NULL),
2,
dyn_tlv,
NULL);
dyn_tlv);
if (!data || data_len < 3)
return NULL;
@@ -431,8 +428,7 @@ struct tlvdb *emv_pki_recover_atc_ex(const struct emv_pk *enc_pk, const struct t
tlvdb_get(db, 0x9f37, NULL),
tlvdb_get(db, 0x9f02, NULL),
tlvdb_get(db, 0x5f2a, NULL),
tlvdb_get(db, 0x9f69, NULL),
NULL);
tlvdb_get(db, 0x9f69, NULL));
if (!data || data_len < 3)
return NULL;
@@ -501,8 +497,7 @@ struct tlvdb *emv_pki_perform_cda_ex(const struct emv_pk *enc_pk, const struct t
unsigned char *data = emv_pki_decode_message(enc_pk, 5, &data_len,
tlvdb_get(this_db, 0x9f4b, NULL),
2,
un_tlv,
NULL);
un_tlv);
if (!data || data_len < 3) {
PrintAndLogEx(WARNING, "ERROR: can't decode message. [%zu bytes]", data_len);
return NULL;
+3 -6
View File
@@ -203,8 +203,7 @@ static struct tlvdb *emv_pki_sign_key(const struct crypto_pk *cp,
cert_tag, rem_tag,
msg, pos,
tlvdb_get(exp_db, exp_tag, NULL),
add_tlv,
NULL);
add_tlv);
free(msg);
if (!db) {
free(exp_db);
@@ -243,8 +242,7 @@ struct tlvdb *emv_pki_sign_dac(const struct crypto_pk *cp, const struct tlv *dac
struct tlvdb *db = emv_pki_sign_message(cp,
0x93, 0,
msg, pos,
sda_tlv,
NULL);
sda_tlv);
free(msg);
@@ -268,8 +266,7 @@ struct tlvdb *emv_pki_sign_idn(const struct crypto_pk *cp, const struct tlv *idn
struct tlvdb *db = emv_pki_sign_message(cp,
0x9f4b, 0,
msg, pos,
dyn_tlv,
NULL);
dyn_tlv);
free(msg);