1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 12:51:22 +04:00

[FL-3766] Fix crash on Ultralight unlock (#3855)

* Fix crash on Ultralight unlock
* Infrared: safe macroses

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Astra
2024-09-06 20:44:32 +09:00
committed by GitHub
parent e0654fe409
commit ad27713f0d
4 changed files with 22 additions and 15 deletions

View File

@@ -37,9 +37,9 @@ typedef enum {
#define INFRARED_ERROR_CODE_MASK (0xFFFFFF00) #define INFRARED_ERROR_CODE_MASK (0xFFFFFF00)
#define INFRARED_ERROR_INDEX_MASK (0x000000FF) #define INFRARED_ERROR_INDEX_MASK (0x000000FF)
#define INFRARED_ERROR_GET_CODE(error) (error & INFRARED_ERROR_CODE_MASK) #define INFRARED_ERROR_GET_CODE(error) ((error) & INFRARED_ERROR_CODE_MASK)
#define INFRARED_ERROR_GET_INDEX(error) (error & INFRARED_ERROR_INDEX_MASK) #define INFRARED_ERROR_GET_INDEX(error) ((error) & INFRARED_ERROR_INDEX_MASK)
#define INFRARED_ERROR_SET_INDEX(code, index) (code |= (index & INFRARED_ERROR_INDEX_MASK)) #define INFRARED_ERROR_SET_INDEX(code, index) ((code) |= ((index) & INFRARED_ERROR_INDEX_MASK))
#define INFRARED_ERROR_PRESENT(error) (INFRARED_ERROR_GET_CODE(error) != InfraredErrorCodeNone) #define INFRARED_ERROR_PRESENT(error) (INFRARED_ERROR_GET_CODE(error) != InfraredErrorCodeNone)
#define INFRARED_ERROR_CHECK(error, test_code) (INFRARED_ERROR_GET_CODE(error) == test_code) #define INFRARED_ERROR_CHECK(error, test_code) (INFRARED_ERROR_GET_CODE(error) == (test_code))

View File

@@ -1,6 +1,6 @@
#include "iso14443_3a_render.h" #include "iso14443_3a_render.h"
void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* const data, size_t size) { void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* data, size_t size) {
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
furi_string_cat_printf(str, " %02X", data[i]); furi_string_cat_printf(str, " %02X", data[i]);
} }

View File

@@ -11,7 +11,7 @@ void nfc_render_iso14443_3a_info(
void nfc_render_iso14443_tech_type(const Iso14443_3aData* data, FuriString* str); void nfc_render_iso14443_tech_type(const Iso14443_3aData* data, FuriString* str);
void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* const data, size_t size); void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* data, size_t size);
void nfc_render_iso14443_3a_brief(const Iso14443_3aData* data, FuriString* str); void nfc_render_iso14443_3a_brief(const Iso14443_3aData* data, FuriString* str);

View File

@@ -10,22 +10,29 @@ static void nfc_render_mf_ultralight_pages_count(const MfUltralightData* data, F
} }
void nfc_render_mf_ultralight_pwd_pack(const MfUltralightData* data, FuriString* str) { void nfc_render_mf_ultralight_pwd_pack(const MfUltralightData* data, FuriString* str) {
MfUltralightConfigPages* config;
bool all_pages = mf_ultralight_is_all_data_read(data); bool all_pages = mf_ultralight_is_all_data_read(data);
if(all_pages) { bool has_config = mf_ultralight_get_config_page(data, &config);
if(!has_config) {
furi_string_cat_printf(str, "\e#Already Unlocked!");
} else if(all_pages) {
furi_string_cat_printf(str, "\e#All Pages Are Unlocked!"); furi_string_cat_printf(str, "\e#All Pages Are Unlocked!");
} else { } else {
furi_string_cat_printf(str, "\e#Some Pages Are Locked!"); furi_string_cat_printf(str, "\e#Some Pages Are Locked!");
} }
MfUltralightConfigPages* config; if(has_config) {
mf_ultralight_get_config_page(data, &config);
furi_string_cat_printf(str, "\nPassword: "); furi_string_cat_printf(str, "\nPassword: ");
nfc_render_iso14443_3a_format_bytes( nfc_render_iso14443_3a_format_bytes(
str, config->password.data, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE); str, config->password.data, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE);
furi_string_cat_printf(str, "\nPACK: "); furi_string_cat_printf(str, "\nPACK: ");
nfc_render_iso14443_3a_format_bytes(str, config->pack.data, MF_ULTRALIGHT_AUTH_PACK_SIZE); nfc_render_iso14443_3a_format_bytes(str, config->pack.data, MF_ULTRALIGHT_AUTH_PACK_SIZE);
} else {
furi_string_cat_printf(str, "\nThis card does not support\npassword protection!");
}
nfc_render_mf_ultralight_pages_count(data, str); nfc_render_mf_ultralight_pages_count(data, str);
} }