From 471f3c50ea7319ff1ed87e3650a17c61d82d6a95 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 8 May 2022 05:57:59 +0300 Subject: [PATCH] nyx: tools: do not allow part manager backup/restore to hang on corruption --- nyx/nyx_gui/frontend/gui_tools_partition_manager.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c index afbe5b7..344cc42 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -96,6 +96,11 @@ static int _backup_and_restore_files(char *path, u32 *total_files, u32 *total_si lv_label_set_text(labels[0], path); dirLength = strlen(path); + + // Hard limit path to 1024 characters. Do not result to error. + if (dirLength > 1024) + goto out; + for (;;) { // Clear file path. @@ -205,6 +210,7 @@ static int _backup_and_restore_files(char *path, u32 *total_files, u32 *total_si } } +out: f_closedir(&dir); return res; @@ -1359,7 +1365,7 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn) sd_mount(); FATFS ram_fs; - char *path = malloc(1024); + char *path = malloc(0x1000); u32 total_files = 0; u32 total_size = 0; @@ -1907,7 +1913,7 @@ static void create_mbox_check_files_total_size() lv_obj_set_top(mbox, true); manual_system_maintenance(true); - char *path = malloc(1024); + char *path = malloc(0x1000); u32 total_files = 0; u32 total_size = 0; path[0] = 0;