From ad27713f0d0abc4d02b8867afea696158b9eb114 Mon Sep 17 00:00:00 2001 From: Astra <93453568+Astrrra@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:44:32 +0900 Subject: [PATCH 1/2] [FL-3766] Fix crash on Ultralight unlock (#3855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix crash on Ultralight unlock * Infrared: safe macroses Co-authored-by: あく --- .../main/infrared/infrared_error_code.h | 8 +++--- .../iso14443_3a/iso14443_3a_render.c | 2 +- .../iso14443_3a/iso14443_3a_render.h | 2 +- .../mf_ultralight/mf_ultralight_render.c | 25 ++++++++++++------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/applications/main/infrared/infrared_error_code.h b/applications/main/infrared/infrared_error_code.h index 2af06bea1..841721b17 100644 --- a/applications/main/infrared/infrared_error_code.h +++ b/applications/main/infrared/infrared_error_code.h @@ -37,9 +37,9 @@ typedef enum { #define INFRARED_ERROR_CODE_MASK (0xFFFFFF00) #define INFRARED_ERROR_INDEX_MASK (0x000000FF) -#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_SET_INDEX(code, index) (code |= (index & INFRARED_ERROR_INDEX_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_SET_INDEX(code, index) ((code) |= ((index) & INFRARED_ERROR_INDEX_MASK)) #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)) diff --git a/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.c b/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.c index 810242fbc..6ceb4bce0 100644 --- a/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.c +++ b/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.c @@ -1,6 +1,6 @@ #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++) { furi_string_cat_printf(str, " %02X", data[i]); } diff --git a/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.h b/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.h index 34e347aa3..b81515566 100644 --- a/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.h +++ b/applications/main/nfc/helpers/protocol_support/iso14443_3a/iso14443_3a_render.h @@ -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_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); diff --git a/applications/main/nfc/helpers/protocol_support/mf_ultralight/mf_ultralight_render.c b/applications/main/nfc/helpers/protocol_support/mf_ultralight/mf_ultralight_render.c index c4ad67ff8..ef83d1942 100644 --- a/applications/main/nfc/helpers/protocol_support/mf_ultralight/mf_ultralight_render.c +++ b/applications/main/nfc/helpers/protocol_support/mf_ultralight/mf_ultralight_render.c @@ -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) { + MfUltralightConfigPages* config; + 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!"); } else { furi_string_cat_printf(str, "\e#Some Pages Are Locked!"); } - MfUltralightConfigPages* config; - mf_ultralight_get_config_page(data, &config); + if(has_config) { + furi_string_cat_printf(str, "\nPassword: "); + nfc_render_iso14443_3a_format_bytes( + str, config->password.data, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE); - furi_string_cat_printf(str, "\nPassword: "); - nfc_render_iso14443_3a_format_bytes( - str, config->password.data, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE); - - furi_string_cat_printf(str, "\nPACK: "); - nfc_render_iso14443_3a_format_bytes(str, config->pack.data, MF_ULTRALIGHT_AUTH_PACK_SIZE); + furi_string_cat_printf(str, "\nPACK: "); + 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); } From 8caa861cc77a050bfa3a686fff75eb1ed9f95e3c Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 6 Sep 2024 15:11:05 +0200 Subject: [PATCH 2/2] Exposed `view_dispatcher_get_event_loop` (#3858) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Exposed view_dispatcher_get_event_loop * Bump api symbols Co-authored-by: あく --- targets/f18/api_symbols.csv | 4 ++-- targets/f7/api_symbols.csv | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index b603813a7..12e5b97e1 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,72.2,, +Version,+,72.3,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, Header,+,applications/services/cli/cli.h,, @@ -2759,7 +2759,7 @@ Function,+,view_dispatcher_alloc,ViewDispatcher*, Function,+,view_dispatcher_attach_to_gui,void,"ViewDispatcher*, Gui*, ViewDispatcherType" Function,+,view_dispatcher_enable_queue,void,ViewDispatcher* Function,+,view_dispatcher_free,void,ViewDispatcher* -Function,-,view_dispatcher_get_event_loop,FuriEventLoop*,ViewDispatcher* +Function,+,view_dispatcher_get_event_loop,FuriEventLoop*,ViewDispatcher* Function,+,view_dispatcher_remove_view,void,"ViewDispatcher*, uint32_t" Function,+,view_dispatcher_run,void,ViewDispatcher* Function,+,view_dispatcher_send_custom_event,void,"ViewDispatcher*, uint32_t" diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 1d5b98fe3..850c84fe0 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,72.2,, +Version,+,72.3,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt_keys_storage.h,, @@ -3600,7 +3600,7 @@ Function,+,view_dispatcher_alloc,ViewDispatcher*, Function,+,view_dispatcher_attach_to_gui,void,"ViewDispatcher*, Gui*, ViewDispatcherType" Function,+,view_dispatcher_enable_queue,void,ViewDispatcher* Function,+,view_dispatcher_free,void,ViewDispatcher* -Function,-,view_dispatcher_get_event_loop,FuriEventLoop*,ViewDispatcher* +Function,+,view_dispatcher_get_event_loop,FuriEventLoop*,ViewDispatcher* Function,+,view_dispatcher_remove_view,void,"ViewDispatcher*, uint32_t" Function,+,view_dispatcher_run,void,ViewDispatcher* Function,+,view_dispatcher_send_custom_event,void,"ViewDispatcher*, uint32_t"