[FL-2811] Fix PVS-Studio warnings (#2142)
Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
@@ -90,7 +90,7 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
|
||||
}
|
||||
FURI_LOG_T(
|
||||
TAG,
|
||||
"Read line: %s, len: %d",
|
||||
"Read line: %s, len: %zu",
|
||||
furi_string_get_cstr(next_line),
|
||||
furi_string_size(next_line));
|
||||
if(furi_string_get_char(next_line, 0) == '#') continue;
|
||||
@@ -101,7 +101,7 @@ MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type) {
|
||||
stream_rewind(dict->stream);
|
||||
|
||||
dict_loaded = true;
|
||||
FURI_LOG_I(TAG, "Loaded dictionary with %ld keys", dict->total_keys);
|
||||
FURI_LOG_I(TAG, "Loaded dictionary with %lu keys", dict->total_keys);
|
||||
} while(false);
|
||||
|
||||
if(!dict_loaded) {
|
||||
@@ -136,7 +136,7 @@ static void mf_classic_dict_str_to_int(FuriString* key_str, uint64_t* key_int) {
|
||||
for(uint8_t i = 0; i < 12; i += 2) {
|
||||
args_char_to_hex(
|
||||
furi_string_get_char(key_str, i), furi_string_get_char(key_str, i + 1), &key_byte_tmp);
|
||||
*key_int |= (uint64_t)key_byte_tmp << 8 * (5 - i / 2);
|
||||
*key_int |= (uint64_t)key_byte_tmp << (8 * (5 - i / 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ bool mf_classic_dict_is_key_present_str(MfClassicDict* dict, FuriString* key) {
|
||||
|
||||
bool key_found = false;
|
||||
stream_rewind(dict->stream);
|
||||
while(!key_found) {
|
||||
while(!key_found) { //-V654
|
||||
if(!stream_read_line(dict->stream, next_line)) break;
|
||||
if(furi_string_get_char(next_line, 0) == '#') continue;
|
||||
if(furi_string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN) continue;
|
||||
@@ -294,7 +294,7 @@ bool mf_classic_dict_find_index_str(MfClassicDict* dict, FuriString* key, uint32
|
||||
bool key_found = false;
|
||||
uint32_t index = 0;
|
||||
stream_rewind(dict->stream);
|
||||
while(!key_found) {
|
||||
while(!key_found) { //-V654
|
||||
if(!stream_read_line(dict->stream, next_line)) break;
|
||||
if(furi_string_get_char(next_line, 0) == '#') continue;
|
||||
if(furi_string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN) continue;
|
||||
|
@@ -221,11 +221,11 @@ static void reader_analyzer_write(
|
||||
data_sent = furi_stream_buffer_send(
|
||||
instance->stream, &header, sizeof(ReaderAnalyzerHeader), FuriWaitForever);
|
||||
if(data_sent != sizeof(ReaderAnalyzerHeader)) {
|
||||
FURI_LOG_W(TAG, "Sent %d out of %d bytes", data_sent, sizeof(ReaderAnalyzerHeader));
|
||||
FURI_LOG_W(TAG, "Sent %zu out of %zu bytes", data_sent, sizeof(ReaderAnalyzerHeader));
|
||||
}
|
||||
data_sent = furi_stream_buffer_send(instance->stream, data, len, FuriWaitForever);
|
||||
if(data_sent != len) {
|
||||
FURI_LOG_W(TAG, "Sent %d out of %d bytes", data_sent, len);
|
||||
FURI_LOG_W(TAG, "Sent %zu out of %u bytes", data_sent, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -576,7 +576,7 @@ static bool nfc_device_save_mifare_df_data(FlipperFormat* file, NfcDevice* dev)
|
||||
tmp = malloc(n_apps * 3);
|
||||
int i = 0;
|
||||
for(MifareDesfireApplication* app = data->app_head; app; app = app->next) {
|
||||
memcpy(tmp + i, app->id, 3);
|
||||
memcpy(tmp + i, app->id, 3); //-V769
|
||||
i += 3;
|
||||
}
|
||||
if(!flipper_format_write_hex(file, "Application IDs", tmp, n_apps * 3)) break;
|
||||
@@ -1085,7 +1085,7 @@ bool nfc_device_save(NfcDevice* dev, const char* dev_name) {
|
||||
saved = true;
|
||||
} while(0);
|
||||
|
||||
if(!saved) {
|
||||
if(!saved) { //-V547
|
||||
dialog_message_show_storage_error(dev->dialogs, "Can not save\nkey file");
|
||||
}
|
||||
furi_string_free(temp_str);
|
||||
|
@@ -453,11 +453,11 @@ void nfc_worker_read_type(NfcWorker* nfc_worker) {
|
||||
event = NfcWorkerEventReadUidNfcA;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(!card_not_detected_notified) {
|
||||
nfc_worker->callback(NfcWorkerEventNoCardDetected, nfc_worker->context);
|
||||
card_not_detected_notified = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!card_not_detected_notified) {
|
||||
nfc_worker->callback(NfcWorkerEventNoCardDetected, nfc_worker->context);
|
||||
card_not_detected_notified = true;
|
||||
}
|
||||
}
|
||||
furi_hal_nfc_sleep();
|
||||
@@ -509,7 +509,7 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) {
|
||||
reader_analyzer_start(nfc_worker->reader_analyzer, ReaderAnalyzerModeDebugLog);
|
||||
}
|
||||
|
||||
while(nfc_worker->state == NfcWorkerStateEmulateApdu) {
|
||||
while(nfc_worker->state == NfcWorkerStateEmulateApdu) { //-V1044
|
||||
if(furi_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, false, 300)) {
|
||||
FURI_LOG_D(TAG, "POS terminal detected");
|
||||
if(emv_card_emulation(&tx_rx)) {
|
||||
@@ -657,7 +657,7 @@ void nfc_worker_mf_classic_dict_attack(NfcWorker* nfc_worker) {
|
||||
}
|
||||
|
||||
FURI_LOG_D(
|
||||
TAG, "Start Dictionary attack, Key Count %ld", mf_classic_dict_get_total_keys(dict));
|
||||
TAG, "Start Dictionary attack, Key Count %lu", mf_classic_dict_get_total_keys(dict));
|
||||
for(size_t i = 0; i < total_sectors; i++) {
|
||||
FURI_LOG_I(TAG, "Sector %d", i);
|
||||
nfc_worker->callback(NfcWorkerEventNewSector, nfc_worker->context);
|
||||
@@ -742,7 +742,7 @@ void nfc_worker_emulate_mf_classic(NfcWorker* nfc_worker) {
|
||||
rfal_platform_spi_acquire();
|
||||
|
||||
furi_hal_nfc_listen_start(nfc_data);
|
||||
while(nfc_worker->state == NfcWorkerStateMfClassicEmulate) {
|
||||
while(nfc_worker->state == NfcWorkerStateMfClassicEmulate) { //-V1044
|
||||
if(furi_hal_nfc_listen_rx(&tx_rx, 300)) {
|
||||
mf_classic_emulator(&emulator, &tx_rx);
|
||||
}
|
||||
@@ -776,7 +776,8 @@ void nfc_worker_write_mf_classic(NfcWorker* nfc_worker) {
|
||||
furi_hal_nfc_sleep();
|
||||
|
||||
FURI_LOG_I(TAG, "Check low level nfc data");
|
||||
if(memcmp(&nfc_data, &nfc_worker->dev_data->nfc_data, sizeof(FuriHalNfcDevData))) {
|
||||
if(memcmp(&nfc_data, &nfc_worker->dev_data->nfc_data, sizeof(FuriHalNfcDevData)) !=
|
||||
0) {
|
||||
FURI_LOG_E(TAG, "Wrong card");
|
||||
nfc_worker->callback(NfcWorkerEventWrongCard, nfc_worker->context);
|
||||
break;
|
||||
@@ -848,7 +849,8 @@ void nfc_worker_update_mf_classic(NfcWorker* nfc_worker) {
|
||||
furi_hal_nfc_sleep();
|
||||
|
||||
FURI_LOG_I(TAG, "Check low level nfc data");
|
||||
if(memcmp(&nfc_data, &nfc_worker->dev_data->nfc_data, sizeof(FuriHalNfcDevData))) {
|
||||
if(memcmp(&nfc_data, &nfc_worker->dev_data->nfc_data, sizeof(FuriHalNfcDevData)) !=
|
||||
0) {
|
||||
FURI_LOG_E(TAG, "Low level nfc data mismatch");
|
||||
nfc_worker->callback(NfcWorkerEventWrongCard, nfc_worker->context);
|
||||
break;
|
||||
|
@@ -73,24 +73,14 @@ bool all_in_one_parser_parse(NfcDeviceData* dev_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the layout is a then the ride count is stored in the first byte of page 8
|
||||
uint8_t ride_count = 0;
|
||||
uint32_t serial = 0;
|
||||
if(all_in_one_get_layout(dev_data) == ALL_IN_ONE_LAYOUT_A) {
|
||||
// If the layout is A then the ride count is stored in the first byte of page 8
|
||||
ride_count = dev_data->mf_ul_data.data[4 * 8];
|
||||
} else if(all_in_one_get_layout(dev_data) == ALL_IN_ONE_LAYOUT_D) {
|
||||
// If the layout is D, the ride count is stored in the second byte of page 9
|
||||
ride_count = dev_data->mf_ul_data.data[4 * 9 + 1];
|
||||
// I hate this with a burning passion.
|
||||
|
||||
// The number starts at the second half of the third byte on page 4, and is 32 bits long
|
||||
// So we get the second half of the third byte, then bytes 4-6, and then the first half of the 7th byte
|
||||
// B8 17 A2 A4 BD becomes 81 7A 2A 4B
|
||||
serial = (dev_data->mf_ul_data.data[4 * 4 + 2] & 0x0F) << 28 |
|
||||
dev_data->mf_ul_data.data[4 * 4 + 3] << 20 |
|
||||
dev_data->mf_ul_data.data[4 * 4 + 4] << 12 |
|
||||
dev_data->mf_ul_data.data[4 * 4 + 5] << 4 |
|
||||
(dev_data->mf_ul_data.data[4 * 4 + 6] >> 4);
|
||||
} else {
|
||||
FURI_LOG_I("all_in_one", "Unknown layout: %d", all_in_one_get_layout(dev_data));
|
||||
ride_count = 137;
|
||||
@@ -110,4 +100,4 @@ bool all_in_one_parser_parse(NfcDeviceData* dev_data) {
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data, "\e#All-In-One\nNumber: %lu\nRides left: %u", serial, ride_count);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -116,26 +116,9 @@ bool plantain_4k_parser_parse(NfcDeviceData* dev_data) {
|
||||
for(size_t i = 0; i < 7; i++) {
|
||||
card_number = (card_number << 8) | card_number_arr[i];
|
||||
}
|
||||
// Convert card number to string
|
||||
FuriString* card_number_str;
|
||||
card_number_str = furi_string_alloc();
|
||||
// Should look like "361301047292848684"
|
||||
furi_string_printf(card_number_str, "%llu", card_number);
|
||||
// Add suffix with luhn checksum (1 digit) to the card number string
|
||||
FuriString* card_number_suffix;
|
||||
card_number_suffix = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(card_number_suffix, "-");
|
||||
furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix));
|
||||
// Free all not needed strings
|
||||
furi_string_free(card_number_suffix);
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data,
|
||||
"\e#Plantain\nN:%s\nBalance:%ld\n",
|
||||
furi_string_get_cstr(card_number_str),
|
||||
balance);
|
||||
furi_string_free(card_number_str);
|
||||
dev_data->parsed_data, "\e#Plantain\nN:%llu-\nBalance:%ld\n", card_number, balance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -89,26 +89,9 @@ bool plantain_parser_parse(NfcDeviceData* dev_data) {
|
||||
for(size_t i = 0; i < 7; i++) {
|
||||
card_number = (card_number << 8) | card_number_arr[i];
|
||||
}
|
||||
// Convert card number to string
|
||||
FuriString* card_number_str;
|
||||
card_number_str = furi_string_alloc();
|
||||
// Should look like "361301047292848684"
|
||||
furi_string_printf(card_number_str, "%llu", card_number);
|
||||
// Add suffix with luhn checksum (1 digit) to the card number string
|
||||
FuriString* card_number_suffix;
|
||||
card_number_suffix = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(card_number_suffix, "-");
|
||||
furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix));
|
||||
// Free all not needed strings
|
||||
furi_string_free(card_number_suffix);
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data,
|
||||
"\e#Plantain\nN:%s\nBalance:%ld\n",
|
||||
furi_string_get_cstr(card_number_str),
|
||||
balance);
|
||||
furi_string_free(card_number_str);
|
||||
dev_data->parsed_data, "\e#Plantain\nN:%llu-\nBalance:%ld\n", card_number, balance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -117,19 +117,6 @@ bool two_cities_parser_parse(NfcDeviceData* dev_data) {
|
||||
for(size_t i = 0; i < 7; i++) {
|
||||
card_number = (card_number << 8) | card_number_arr[i];
|
||||
}
|
||||
// Convert card number to string
|
||||
FuriString* card_number_str;
|
||||
card_number_str = furi_string_alloc();
|
||||
// Should look like "361301047292848684"
|
||||
furi_string_printf(card_number_str, "%llu", card_number);
|
||||
// Add suffix with luhn checksum (1 digit) to the card number string
|
||||
FuriString* card_number_suffix;
|
||||
card_number_suffix = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(card_number_suffix, "-");
|
||||
furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix));
|
||||
// Free all not needed strings
|
||||
furi_string_free(card_number_suffix);
|
||||
|
||||
// =====
|
||||
// --PLANTAIN--
|
||||
@@ -149,12 +136,11 @@ bool two_cities_parser_parse(NfcDeviceData* dev_data) {
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data,
|
||||
"\e#Troika+Plantain\nPN: %s\nPB: %ld rur.\nTN: %ld\nTB: %d rur.\n",
|
||||
furi_string_get_cstr(card_number_str),
|
||||
"\e#Troika+Plantain\nPN: %llu-\nPB: %ld rur.\nTN: %ld\nTB: %d rur.\n",
|
||||
card_number,
|
||||
balance,
|
||||
troika_number,
|
||||
troika_balance);
|
||||
furi_string_free(card_number_str);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -4,7 +4,8 @@
|
||||
|
||||
// Algorithm from https://github.com/RfidResearchGroup/proxmark3.git
|
||||
|
||||
#define SWAPENDIAN(x) (x = (x >> 8 & 0xff00ff) | (x & 0xff00ff) << 8, x = x >> 16 | x << 16)
|
||||
#define SWAPENDIAN(x) \
|
||||
((x) = ((x) >> 8 & 0xff00ff) | ((x)&0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16)
|
||||
#define LF_POLY_ODD (0x29CE5C)
|
||||
#define LF_POLY_EVEN (0x870804)
|
||||
|
||||
|
@@ -245,7 +245,8 @@ bool mf_classic_is_allowed_access_sector_trailer(
|
||||
case MfClassicActionKeyARead: {
|
||||
return false;
|
||||
}
|
||||
case MfClassicActionKeyAWrite: {
|
||||
case MfClassicActionKeyAWrite:
|
||||
case MfClassicActionKeyBWrite: {
|
||||
return (
|
||||
(key == MfClassicKeyA && (AC == 0x00 || AC == 0x01)) ||
|
||||
(key == MfClassicKeyB && (AC == 0x04 || AC == 0x03)));
|
||||
@@ -253,11 +254,6 @@ bool mf_classic_is_allowed_access_sector_trailer(
|
||||
case MfClassicActionKeyBRead: {
|
||||
return (key == MfClassicKeyA && (AC == 0x00 || AC == 0x02 || AC == 0x01));
|
||||
}
|
||||
case MfClassicActionKeyBWrite: {
|
||||
return (
|
||||
(key == MfClassicKeyA && (AC == 0x00 || AC == 0x01)) ||
|
||||
(key == MfClassicKeyB && (AC == 0x04 || AC == 0x03)));
|
||||
}
|
||||
case MfClassicActionACRead: {
|
||||
return (
|
||||
(key == MfClassicKeyA) ||
|
||||
@@ -734,7 +730,7 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
|
||||
MfClassicKey access_key = MfClassicKeyA;
|
||||
|
||||
// Read command
|
||||
while(!command_processed) {
|
||||
while(!command_processed) { //-V654
|
||||
if(!is_encrypted) {
|
||||
crypto1_reset(&emulator->crypto);
|
||||
memcpy(plain_data, tx_rx->rx_data, tx_rx->rx_bits / 8);
|
||||
@@ -850,7 +846,7 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
|
||||
if(mf_classic_is_sector_trailer(block)) {
|
||||
if(!mf_classic_is_allowed_access(
|
||||
emulator, block, access_key, MfClassicActionKeyARead)) {
|
||||
memset(block_data, 0, 6);
|
||||
memset(block_data, 0, 6); //-V1086
|
||||
}
|
||||
if(!mf_classic_is_allowed_access(
|
||||
emulator, block, access_key, MfClassicActionKeyBRead)) {
|
||||
@@ -860,22 +856,16 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
|
||||
emulator, block, access_key, MfClassicActionACRead)) {
|
||||
memset(&block_data[6], 0, 4);
|
||||
}
|
||||
} else {
|
||||
if(!mf_classic_is_allowed_access(
|
||||
emulator, block, access_key, MfClassicActionDataRead)) {
|
||||
// Send NACK
|
||||
uint8_t nack = 0x04;
|
||||
if(is_encrypted) {
|
||||
crypto1_encrypt(
|
||||
&emulator->crypto, NULL, &nack, 4, tx_rx->tx_data, tx_rx->tx_parity);
|
||||
} else {
|
||||
tx_rx->tx_data[0] = nack;
|
||||
}
|
||||
tx_rx->tx_rx_type = FuriHalNfcTxRxTransparent;
|
||||
tx_rx->tx_bits = 4;
|
||||
furi_hal_nfc_tx_rx(tx_rx, 300);
|
||||
break;
|
||||
}
|
||||
} else if(!mf_classic_is_allowed_access(
|
||||
emulator, block, access_key, MfClassicActionDataRead)) {
|
||||
// Send NACK
|
||||
uint8_t nack = 0x04;
|
||||
crypto1_encrypt(
|
||||
&emulator->crypto, NULL, &nack, 4, tx_rx->tx_data, tx_rx->tx_parity);
|
||||
tx_rx->tx_rx_type = FuriHalNfcTxRxTransparent;
|
||||
tx_rx->tx_bits = 4;
|
||||
furi_hal_nfc_tx_rx(tx_rx, 300);
|
||||
break;
|
||||
}
|
||||
nfca_append_crc16(block_data, 16);
|
||||
|
||||
@@ -908,7 +898,7 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
|
||||
if(mf_classic_is_sector_trailer(block)) {
|
||||
if(mf_classic_is_allowed_access(
|
||||
emulator, block, access_key, MfClassicActionKeyAWrite)) {
|
||||
memcpy(block_data, plain_data, 6);
|
||||
memcpy(block_data, plain_data, 6); //-V1086
|
||||
}
|
||||
if(mf_classic_is_allowed_access(
|
||||
emulator, block, access_key, MfClassicActionKeyBWrite)) {
|
||||
@@ -924,7 +914,7 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
|
||||
memcpy(block_data, plain_data, MF_CLASSIC_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
if(memcmp(block_data, emulator->data.block[block].value, MF_CLASSIC_BLOCK_SIZE)) {
|
||||
if(memcmp(block_data, emulator->data.block[block].value, MF_CLASSIC_BLOCK_SIZE) != 0) {
|
||||
memcpy(emulator->data.block[block].value, block_data, MF_CLASSIC_BLOCK_SIZE);
|
||||
emulator->data_changed = true;
|
||||
}
|
||||
@@ -1060,7 +1050,8 @@ bool mf_classic_write_sector(
|
||||
bool write_success = true;
|
||||
for(size_t i = first_block; i < first_block + total_blocks; i++) {
|
||||
// Compare blocks
|
||||
if(memcmp(dest_data->block[i].value, src_data->block[i].value, MF_CLASSIC_BLOCK_SIZE)) {
|
||||
if(memcmp(dest_data->block[i].value, src_data->block[i].value, MF_CLASSIC_BLOCK_SIZE) !=
|
||||
0) {
|
||||
bool key_a_write_allowed = mf_classic_is_allowed_access_data_block(
|
||||
dest_data, i, MfClassicKeyA, MfClassicActionDataWrite);
|
||||
bool key_b_write_allowed = mf_classic_is_allowed_access_data_block(
|
||||
|
@@ -108,7 +108,7 @@ void mf_df_cat_version(MifareDesfireVersion* version, FuriString* out) {
|
||||
}
|
||||
|
||||
void mf_df_cat_free_mem(MifareDesfireFreeMemory* free_mem, FuriString* out) {
|
||||
furi_string_cat_printf(out, "freeMem %ld\n", free_mem->bytes);
|
||||
furi_string_cat_printf(out, "freeMem %lu\n", free_mem->bytes);
|
||||
}
|
||||
|
||||
void mf_df_cat_key_settings(MifareDesfireKeySettings* ks, FuriString* out) {
|
||||
@@ -191,10 +191,10 @@ void mf_df_cat_file(MifareDesfireFile* file, FuriString* out) {
|
||||
case MifareDesfireFileTypeValue:
|
||||
size = 4;
|
||||
furi_string_cat_printf(
|
||||
out, "lo %ld hi %ld\n", file->settings.value.lo_limit, file->settings.value.hi_limit);
|
||||
out, "lo %lu hi %lu\n", file->settings.value.lo_limit, file->settings.value.hi_limit);
|
||||
furi_string_cat_printf(
|
||||
out,
|
||||
"limit %ld enabled %d\n",
|
||||
"limit %lu enabled %d\n",
|
||||
file->settings.value.limited_credit_value,
|
||||
file->settings.value.limited_credit_enabled);
|
||||
break;
|
||||
@@ -203,7 +203,7 @@ void mf_df_cat_file(MifareDesfireFile* file, FuriString* out) {
|
||||
size = file->settings.record.size;
|
||||
num = file->settings.record.cur;
|
||||
furi_string_cat_printf(out, "size %d\n", size);
|
||||
furi_string_cat_printf(out, "num %d max %ld\n", num, file->settings.record.max);
|
||||
furi_string_cat_printf(out, "num %d max %lu\n", num, file->settings.record.max);
|
||||
break;
|
||||
}
|
||||
uint8_t* data = file->contents;
|
||||
@@ -220,8 +220,9 @@ void mf_df_cat_file(MifareDesfireFile* file, FuriString* out) {
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < 4 && ch + i < size; i++) {
|
||||
if(isprint(data[rec * size + ch + i])) {
|
||||
furi_string_cat_printf(out, "%c", data[rec * size + ch + i]);
|
||||
const size_t data_index = rec * size + ch + i;
|
||||
if(isprint(data[data_index])) {
|
||||
furi_string_cat_printf(out, "%c", data[data_index]);
|
||||
} else {
|
||||
furi_string_cat_printf(out, ".");
|
||||
}
|
||||
@@ -547,7 +548,8 @@ bool mf_df_read_card(FuriHalNfcTxRxContext* tx_rx, MifareDesfireData* data) {
|
||||
for(MifareDesfireApplication* app = data->app_head; app; app = app->next) {
|
||||
tx_rx->tx_bits = 8 * mf_df_prepare_select_application(tx_rx->tx_data, app->id);
|
||||
if(!furi_hal_nfc_tx_rx_full(tx_rx) ||
|
||||
!mf_df_parse_select_application_response(tx_rx->rx_data, tx_rx->rx_bits / 8)) {
|
||||
!mf_df_parse_select_application_response(
|
||||
tx_rx->rx_data, tx_rx->rx_bits / 8)) { //-V1051
|
||||
FURI_LOG_W(TAG, "Bad exchange selecting application");
|
||||
continue;
|
||||
}
|
||||
|
@@ -170,6 +170,7 @@ bool mf_ultralight_read_version(
|
||||
}
|
||||
|
||||
bool mf_ultralight_authenticate(FuriHalNfcTxRxContext* tx_rx, uint32_t key, uint16_t* pack) {
|
||||
furi_assert(pack);
|
||||
bool authenticated = false;
|
||||
|
||||
do {
|
||||
@@ -189,9 +190,7 @@ bool mf_ultralight_authenticate(FuriHalNfcTxRxContext* tx_rx, uint32_t key, uint
|
||||
break;
|
||||
}
|
||||
|
||||
if(pack != NULL) {
|
||||
*pack = (tx_rx->rx_data[1] << 8) | tx_rx->rx_data[0];
|
||||
}
|
||||
*pack = (tx_rx->rx_data[1] << 8) | tx_rx->rx_data[0];
|
||||
|
||||
FURI_LOG_I(TAG, "Auth success. Password: %08lX. PACK: %04X", key, *pack);
|
||||
authenticated = true;
|
||||
@@ -492,7 +491,7 @@ MfUltralightConfigPages* mf_ultralight_get_config_pages(MfUltralightData* data)
|
||||
} else if(
|
||||
data->type >= MfUltralightTypeNTAGI2CPlus1K &&
|
||||
data->type <= MfUltralightTypeNTAGI2CPlus2K) {
|
||||
return (MfUltralightConfigPages*)&data->data[0xe3 * 4];
|
||||
return (MfUltralightConfigPages*)&data->data[0xe3 * 4]; //-V641
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -561,7 +560,7 @@ bool mf_ultralight_read_pages_direct(
|
||||
FURI_LOG_D(TAG, "Failed to read pages %d - %d", start_index, start_index + 3);
|
||||
return false;
|
||||
}
|
||||
memcpy(data, tx_rx->rx_data, 16);
|
||||
memcpy(data, tx_rx->rx_data, 16); //-V1086
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -584,7 +583,8 @@ bool mf_ultralight_read_pages(
|
||||
curr_sector_index = tag_sector;
|
||||
}
|
||||
|
||||
FURI_LOG_D(TAG, "Reading pages %d - %d", i, i + (valid_pages > 4 ? 4 : valid_pages) - 1);
|
||||
FURI_LOG_D(
|
||||
TAG, "Reading pages %zu - %zu", i, i + (valid_pages > 4 ? 4 : valid_pages) - 1U);
|
||||
tx_rx->tx_data[0] = MF_UL_READ_CMD;
|
||||
tx_rx->tx_data[1] = tag_page;
|
||||
tx_rx->tx_bits = 16;
|
||||
@@ -593,9 +593,9 @@ bool mf_ultralight_read_pages(
|
||||
if(!furi_hal_nfc_tx_rx(tx_rx, 50) || tx_rx->rx_bits < 16 * 8) {
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Failed to read pages %d - %d",
|
||||
"Failed to read pages %zu - %zu",
|
||||
i,
|
||||
i + (valid_pages > 4 ? 4 : valid_pages) - 1);
|
||||
i + (valid_pages > 4 ? 4 : valid_pages) - 1U);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -857,7 +857,7 @@ static void mf_ul_ntag_i2c_fill_cross_area_read(
|
||||
}
|
||||
|
||||
if(apply) {
|
||||
while(tx_page_offset < 0 && page_length > 0) {
|
||||
while(tx_page_offset < 0 && page_length > 0) { //-V614
|
||||
++tx_page_offset;
|
||||
++data_page_offset;
|
||||
--page_length;
|
||||
@@ -987,9 +987,9 @@ static bool mf_ul_check_lock(MfUltralightEmulator* emulator, int16_t write_page)
|
||||
switch(emulator->data.type) {
|
||||
// low byte LSB range, MSB range
|
||||
case MfUltralightTypeNTAG203:
|
||||
if(write_page >= 16 && write_page <= 27)
|
||||
if(write_page >= 16 && write_page <= 27) //-V560
|
||||
shift = (write_page - 16) / 4 + 1;
|
||||
else if(write_page >= 28 && write_page <= 39)
|
||||
else if(write_page >= 28 && write_page <= 39) //-V560
|
||||
shift = (write_page - 28) / 4 + 5;
|
||||
else if(write_page == 41)
|
||||
shift = 12;
|
||||
@@ -1216,7 +1216,7 @@ static void mf_ul_emulate_write(
|
||||
page_buff[0] = new_locks & 0xff;
|
||||
page_buff[1] = new_locks >> 8;
|
||||
page_buff[2] = new_block_locks;
|
||||
if(emulator->data.type >= MfUltralightTypeUL21 &&
|
||||
if(emulator->data.type >= MfUltralightTypeUL21 && //-V1016
|
||||
emulator->data.type <= MfUltralightTypeNTAG216)
|
||||
page_buff[3] = MF_UL_TEARING_FLAG_DEFAULT;
|
||||
else
|
||||
|
Reference in New Issue
Block a user