pedantic fixes

This commit is contained in:
iceman1001 2023-11-03 12:52:01 +01:00
commit c793363b4f
7 changed files with 70 additions and 73 deletions

View file

@ -120,7 +120,7 @@ static emrtd_hashalg_t hashalg_table[] = {
{"SHA-1", sha1hash, 20, 7, {0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A}}, {"SHA-1", sha1hash, 20, 7, {0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A}},
{"SHA-256", sha256hash, 32, 11, {0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01}}, {"SHA-256", sha256hash, 32, 11, {0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01}},
{"SHA-512", sha512hash, 64, 11, {0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03}}, {"SHA-512", sha512hash, 64, 11, {0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03}},
{NULL, NULL, 0, 0, {}} {NULL, NULL, 0, 0, {0}}
}; };
static emrtd_pacealg_t pacealg_table[] = { static emrtd_pacealg_t pacealg_table[] = {
@ -141,7 +141,7 @@ static emrtd_pacealg_t pacealg_table[] = {
{"ECDH, Integrated Mapping, AES-CMAC-128", NULL, {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x02}}, {"ECDH, Integrated Mapping, AES-CMAC-128", NULL, {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x02}},
{"ECDH, Integrated Mapping, AES-CMAC-192", NULL, {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x03}}, {"ECDH, Integrated Mapping, AES-CMAC-192", NULL, {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x03}},
{"ECDH, Integrated Mapping, AES-CMAC-256", NULL, {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x04}}, {"ECDH, Integrated Mapping, AES-CMAC-256", NULL, {0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x04}},
{NULL, NULL, {}} {NULL, NULL, {0}}
}; };
static emrtd_pacesdp_t pacesdp_table[] = { static emrtd_pacesdp_t pacesdp_table[] = {

View file

@ -429,7 +429,7 @@ static void TexcomReverseCode(const uint8_t *code, int length, uint8_t *reverse_
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
reverse_code[i] = code[(length - 1) - i]; reverse_code[i] = code[(length - 1) - i];
} }
}; }
static int texkom_get_type(texkom_card_select_t *card, bool verbose) { static int texkom_get_type(texkom_card_select_t *card, bool verbose) {
@ -493,7 +493,7 @@ static int texkom_get_type(texkom_card_select_t *card, bool verbose) {
noiselvl = TEXKOM_NOISE_THRESHOLD; noiselvl = TEXKOM_NOISE_THRESHOLD;
} }
uint32_t implengths[256] = {}; uint32_t implengths[256] = { 0 };
uint32_t implengthslen = 0; uint32_t implengthslen = 0;
uint32_t impulseindx = 0; uint32_t impulseindx = 0;
uint32_t impulsecnt = 0; uint32_t impulsecnt = 0;
@ -707,7 +707,7 @@ static int CmdHFTexkomReader(const char *Cmd) {
//PrintAndLogEx(WARNING, "--- indx: %d, len: %d, max: %d, noise: %d", sindx, slen, maxlvl, noiselvl); //PrintAndLogEx(WARNING, "--- indx: %d, len: %d, max: %d, noise: %d", sindx, slen, maxlvl, noiselvl);
uint32_t implengths[256] = {}; uint32_t implengths[256] = { 0 };
uint32_t implengthslen = 0; uint32_t implengthslen = 0;
uint32_t impulseindx = 0; uint32_t impulseindx = 0;
uint32_t impulsecnt = 0; uint32_t impulsecnt = 0;
@ -872,7 +872,7 @@ static int CmdHFTexkomSim(const char *Cmd) {
uint8_t data[8]; uint8_t data[8];
uint8_t modulation; uint8_t modulation;
uint32_t timeout; uint32_t timeout;
} PACKED payload = {}; } PACKED payload = {0};
bool verbose = arg_get_lit(ctx, 1); bool verbose = arg_get_lit(ctx, 1);
payload.modulation = 0; // tk-13 payload.modulation = 0; // tk-13

View file

@ -586,10 +586,10 @@ static command_t CommandTable[] = {
int CmdHFVAS(const char *Cmd) { int CmdHFVAS(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
return CmdsParse(CommandTable, Cmd); return CmdsParse(CommandTable, Cmd);
}; }
static int CmdHelp(const char *Cmd) { static int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far (void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable); CmdsHelp(CommandTable);
return PM3_SUCCESS; return PM3_SUCCESS;
}; }

View file

@ -108,20 +108,20 @@ typedef struct {
return r->value; \ return r->value; \
} }
MAKE_ENUM_TYPE(uint8_t); MAKE_ENUM_TYPE(uint8_t)
// KSX6924LookupCardType // KSX6924LookupCardType
MAKE_ENUM_CONST(CardType, uint8_t, MAKE_ENUM_CONST(CardType, uint8_t,
{ 0x00, "Pre-paid" }, { 0x00, "Pre-paid" },
{ 0x10, "Post-pay" }, { 0x10, "Post-pay" },
{ 0x20, "Mobile post-pay" }, { 0x20, "Mobile post-pay" },
); )
// KSX6924LookupAlg // KSX6924LookupAlg
MAKE_ENUM_CONST(Alg, uint8_t, MAKE_ENUM_CONST(Alg, uint8_t,
{ 0x00, "SEED" }, { 0x00, "SEED" },
{ 0x10, "3DES" }, { 0x10, "3DES" },
); )
// KSX6924LookupTMoneyIDCenter // KSX6924LookupTMoneyIDCenter
MAKE_ENUM_CONST(TMoneyIDCenter, uint8_t, MAKE_ENUM_CONST(TMoneyIDCenter, uint8_t,
@ -139,20 +139,17 @@ MAKE_ENUM_CONST(TMoneyIDCenter, uint8_t,
{ 0x0b, "EB Card Corporation" }, { 0x0b, "EB Card Corporation" },
{ 0x0c, "Seoul Bus Transport Association" }, { 0x0c, "Seoul Bus Transport Association" },
{ 0x0d, "Cardnet" }, { 0x0d, "Cardnet" },
); )
// KSX6924LookupTMoneyUserCode // KSX6924LookupTMoneyUserCode
MAKE_ENUM_CONST(TMoneyUserCode, uint8_t, MAKE_ENUM_CONST(TMoneyUserCode, uint8_t,
{ 0x01, "Regular/normal" }, { 0x01, "Regular/normal" },
{ 0x02, "Child" }, { 0x02, "Child" },
{ 0x04, "Youth" }, { 0x04, "Youth" },
{ 0x06, "elderly" }, { 0x06, "elderly" },
{ 0x0f, "Test" }, { 0x0f, "Test" },
{ 0xff, "Inactive" }, { 0xff, "Inactive" },
); )
// KSX6924LookupTMoneyDisRate // KSX6924LookupTMoneyDisRate
MAKE_ENUM_CONST(TMoneyDisRate, uint8_t, MAKE_ENUM_CONST(TMoneyDisRate, uint8_t,
@ -163,7 +160,7 @@ MAKE_ENUM_CONST(TMoneyDisRate, uint8_t,
{ 0x20, "Merit, basic" }, { 0x20, "Merit, basic" },
{ 0x21, "Merit, companion" }, { 0x21, "Merit, companion" },
); )
// KSX6924LookupTMoneyTCode // KSX6924LookupTMoneyTCode
MAKE_ENUM_CONST(TMoneyTCode, uint8_t, MAKE_ENUM_CONST(TMoneyTCode, uint8_t,
@ -171,7 +168,7 @@ MAKE_ENUM_CONST(TMoneyTCode, uint8_t,
{ 0x01, "SK Telecom" }, { 0x01, "SK Telecom" },
{ 0x02, "Korea Telecom" }, { 0x02, "Korea Telecom" },
{ 0x03, "LG Uplus" }, { 0x03, "LG Uplus" },
); )
// KSX6924LookupTMoneyCCode // KSX6924LookupTMoneyCCode
MAKE_ENUM_CONST(TMoneyCCode, uint8_t, MAKE_ENUM_CONST(TMoneyCCode, uint8_t,
@ -187,7 +184,7 @@ MAKE_ENUM_CONST(TMoneyCCode, uint8_t,
{ 0x09, "Woori Card" }, { 0x09, "Woori Card" },
{ 0x0a, "Hana SK Card" }, { 0x0a, "Hana SK Card" },
{ 0x0b, "Hyundai Card" }, { 0x0b, "Hyundai Card" },
); )
static const char *KSX6924_UNKNOWN = "Unknown"; static const char *KSX6924_UNKNOWN = "Unknown";

View file

@ -788,11 +788,11 @@ bool desfire_crc32_check(uint8_t *data, const size_t len, uint8_t *crc) {
} }
void iso14443a_crc_append(uint8_t *data, size_t len) { void iso14443a_crc_append(uint8_t *data, size_t len) {
return compute_crc(CRC_14443_A, data, len, data + len, data + len + 1); compute_crc(CRC_14443_A, data, len, data + len, data + len + 1);
} }
void iso14443a_crc(uint8_t *data, size_t len, uint8_t *pbtCrc) { void iso14443a_crc(uint8_t *data, size_t len, uint8_t *pbtCrc) {
return compute_crc(CRC_14443_A, data, len, pbtCrc, pbtCrc + 1); compute_crc(CRC_14443_A, data, len, pbtCrc, pbtCrc + 1);
} }
bool iso14443a_crc_check(uint8_t *data, const size_t len, uint8_t *crc) { bool iso14443a_crc_check(uint8_t *data, const size_t len, uint8_t *crc) {

View file

@ -94,7 +94,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
g_conn.send_via_local_ip = false; g_conn.send_via_local_ip = false;
g_conn.send_via_ip = PM3_NONE; g_conn.send_via_ip = PM3_NONE;
char *prefix = strdup(pcPortName); char *prefix = str_dup(pcPortName);
if (prefix == NULL) { if (prefix == NULL) {
PrintAndLogEx(ERR, "error: string duplication"); PrintAndLogEx(ERR, "error: string duplication");
free(sp); free(sp);
@ -112,7 +112,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
struct addrinfo *addr = NULL, *rp; struct addrinfo *addr = NULL, *rp;
char *addrPortStr = strdup(pcPortName + 4); char *addrPortStr = str_dup(pcPortName + 4);
char *addrstr = addrPortStr; char *addrstr = addrPortStr;
const char *portstr; const char *portstr;
if (addrPortStr == NULL) { if (addrPortStr == NULL) {
@ -303,7 +303,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
struct addrinfo *addr = NULL, *rp; struct addrinfo *addr = NULL, *rp;
char *addrPortStr = strdup(pcPortName + 4); char *addrPortStr = str_dup(pcPortName + 4);
char *addrstr = addrPortStr; char *addrstr = addrPortStr;
const char *portstr; const char *portstr;
if (addrPortStr == NULL) { if (addrPortStr == NULL) {

View file

@ -95,7 +95,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
g_conn.send_via_local_ip = false; g_conn.send_via_local_ip = false;
g_conn.send_via_ip = PM3_NONE; g_conn.send_via_ip = PM3_NONE;
char *prefix = strdup(pcPortName); char *prefix = str_dup(pcPortName);
if (prefix == NULL) { if (prefix == NULL) {
PrintAndLogEx(ERR, "error: string duplication"); PrintAndLogEx(ERR, "error: string duplication");
free(sp); free(sp);
@ -114,7 +114,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
struct addrinfo *addr = NULL, *rp; struct addrinfo *addr = NULL, *rp;
char *addrPortStr = strdup(pcPortName + 4); char *addrPortStr = str_dup(pcPortName + 4);
char *addrstr = addrPortStr; char *addrstr = addrPortStr;
const char *portstr; const char *portstr;
if (addrPortStr == NULL) { if (addrPortStr == NULL) {
@ -321,7 +321,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
struct addrinfo *addr = NULL, *rp; struct addrinfo *addr = NULL, *rp;
char *addrPortStr = strdup(pcPortName + 4); char *addrPortStr = str_dup(pcPortName + 4);
char *addrstr = addrPortStr; char *addrstr = addrPortStr;
const char *portstr; const char *portstr;
if (addrPortStr == NULL) { if (addrPortStr == NULL) {