From 9699914d1c95cb58bc16b8c3b3221c8aafc34de1 Mon Sep 17 00:00:00 2001 From: acegoal07 Date: Thu, 18 Jan 2024 14:42:35 +0000 Subject: [PATCH] Update emulation.c --- scences/emulation.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scences/emulation.c b/scences/emulation.c index a22577f4e66..9cc74a6afe8 100644 --- a/scences/emulation.c +++ b/scences/emulation.c @@ -95,8 +95,9 @@ int32_t nfc_playlist_emulation_task(void* context) { int time_counter_ms = (options_emulate_timeout[nfc_playlist->emulate_timeout]*1000); if (storage_file_exists(storage, file_path) == false) { - char popup_header_text[(18 + strlen(file_name))]; - snprintf(popup_header_text, (18 + strlen(file_name)), "%s\n%s", "ERROR not found:", file_name); + int popup_header_text_size = strlen(file_name) + 18; + char popup_header_text[popup_header_text_size]; + snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR not found:", file_name); popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop); start_blink(nfc_playlist, NfcPlaylistLedState_Error); while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) { @@ -109,8 +110,9 @@ int32_t nfc_playlist_emulation_task(void* context) { } else if (strcasestr(file_ext, "nfc") == NULL) { - char popup_header_text[(21 + strlen(file_name))]; - snprintf(popup_header_text, (21 + strlen(file_name)), "%s\n%s", "ERROR invalid file:", file_name); + int popup_header_text_size = strlen(file_name) + 21; + char popup_header_text[popup_header_text_size]; + snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR invalid file:", file_name); popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop); start_blink(nfc_playlist, NfcPlaylistLedState_Error); while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) { @@ -123,8 +125,9 @@ int32_t nfc_playlist_emulation_task(void* context) { } else { - char popup_header_text[(12 + strlen(file_name))]; - snprintf(popup_header_text, (12 + strlen(file_name)), "%s\n%s", "Emulating:", file_name); + int popup_header_text_size = strlen(file_name) + 12; + char popup_header_text[popup_header_text_size]; + snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "Emulating:", file_name); popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop); nfc_playlist_worker_set_nfc_data(nfc_playlist->nfc_playlist_worker, file_path); nfc_playlist_worker_start(nfc_playlist->nfc_playlist_worker);