mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
cppcheck fixes
This commit is contained in:
parent
5ff043e5ab
commit
0254b2a63a
3 changed files with 14 additions and 4 deletions
|
@ -72,10 +72,17 @@ void DesfireClearIV(DesfireContext_t *ctx) {
|
||||||
|
|
||||||
void DesfireSetKey(DesfireContext_t *ctx, uint8_t keyNum, DesfireCryptoAlgorithm keyType, uint8_t *key) {
|
void DesfireSetKey(DesfireContext_t *ctx, uint8_t keyNum, DesfireCryptoAlgorithm keyType, uint8_t *key) {
|
||||||
DesfireClearContext(ctx);
|
DesfireClearContext(ctx);
|
||||||
|
if (key == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
DesfireSetKeyNoClear(ctx, keyNum, keyType, key);
|
DesfireSetKeyNoClear(ctx, keyNum, keyType, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesfireSetKeyNoClear(DesfireContext_t *ctx, uint8_t keyNum, DesfireCryptoAlgorithm keyType, uint8_t *key) {
|
void DesfireSetKeyNoClear(DesfireContext_t *ctx, uint8_t keyNum, DesfireCryptoAlgorithm keyType, uint8_t *key) {
|
||||||
|
|
||||||
|
if (key == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
ctx->keyNum = keyNum;
|
ctx->keyNum = keyNum;
|
||||||
ctx->keyType = keyType;
|
ctx->keyType = keyType;
|
||||||
memcpy(ctx->key, key, desfire_get_key_length(keyType));
|
memcpy(ctx->key, key, desfire_get_key_length(keyType));
|
||||||
|
@ -93,9 +100,10 @@ void DesfireSetCommMode(DesfireContext_t *ctx, DesfireCommunicationMode commMode
|
||||||
void DesfireSetKdf(DesfireContext_t *ctx, uint8_t kdfAlgo, uint8_t *kdfInput, uint8_t kdfInputLen) {
|
void DesfireSetKdf(DesfireContext_t *ctx, uint8_t kdfAlgo, uint8_t *kdfInput, uint8_t kdfInputLen) {
|
||||||
ctx->kdfAlgo = kdfAlgo;
|
ctx->kdfAlgo = kdfAlgo;
|
||||||
ctx->kdfInputLen = kdfInputLen;
|
ctx->kdfInputLen = kdfInputLen;
|
||||||
if (kdfInputLen)
|
if (kdfInputLen) {
|
||||||
memcpy(ctx->kdfInput, kdfInput, kdfInputLen);
|
memcpy(ctx->kdfInput, kdfInput, kdfInputLen);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DesfireIsAuthenticated(DesfireContext_t *dctx) {
|
bool DesfireIsAuthenticated(DesfireContext_t *dctx) {
|
||||||
return dctx->secureChannel != DACNone;
|
return dctx->secureChannel != DACNone;
|
||||||
|
|
|
@ -648,6 +648,10 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
int rows;
|
int rows;
|
||||||
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
|
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
|
||||||
rl_get_screen_size(&rows, &cols);
|
rl_get_screen_size(&rows, &cols);
|
||||||
|
|
||||||
|
if (cols < 36)
|
||||||
|
return;
|
||||||
|
|
||||||
(void) rows;
|
(void) rows;
|
||||||
if (prev_cols > cols) {
|
if (prev_cols > cols) {
|
||||||
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
|
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
|
||||||
|
@ -655,8 +659,6 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
prev_cols = cols;
|
prev_cols = cols;
|
||||||
#endif
|
#endif
|
||||||
int width = cols - 35;
|
int width = cols - 35;
|
||||||
if (width < 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#define PERCENTAGE(V, T) ((V * width) / T)
|
#define PERCENTAGE(V, T) ((V * width) / T)
|
||||||
// x/8 fractional part of the percentage
|
// x/8 fractional part of the percentage
|
||||||
|
|
|
@ -1422,7 +1422,7 @@ int HIDFindCardFormat(const char *format) {
|
||||||
bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
|
bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
|
||||||
memset(packed, 0, sizeof(wiegand_message_t));
|
memset(packed, 0, sizeof(wiegand_message_t));
|
||||||
|
|
||||||
if (format_idx < 0 || format_idx >= ARRAYLEN(FormatTable) - 1)
|
if ((format_idx < 0) || (format_idx >= ARRAYLEN(FormatTable) - 1) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return FormatTable[format_idx].Pack(card, packed, preamble);
|
return FormatTable[format_idx].Pack(card, packed, preamble);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue