nyx: tools: do not allow part manager backup/restore to hang on corruption

This commit is contained in:
CTCaer 2022-05-08 05:57:59 +03:00
parent 6d66bfc168
commit 471f3c50ea

View file

@ -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); lv_label_set_text(labels[0], path);
dirLength = strlen(path); dirLength = strlen(path);
// Hard limit path to 1024 characters. Do not result to error.
if (dirLength > 1024)
goto out;
for (;;) for (;;)
{ {
// Clear file path. // 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); f_closedir(&dir);
return res; return res;
@ -1359,7 +1365,7 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
sd_mount(); sd_mount();
FATFS ram_fs; FATFS ram_fs;
char *path = malloc(1024); char *path = malloc(0x1000);
u32 total_files = 0; u32 total_files = 0;
u32 total_size = 0; u32 total_size = 0;
@ -1907,7 +1913,7 @@ static void create_mbox_check_files_total_size()
lv_obj_set_top(mbox, true); lv_obj_set_top(mbox, true);
manual_system_maintenance(true); manual_system_maintenance(true);
char *path = malloc(1024); char *path = malloc(0x1000);
u32 total_files = 0; u32 total_files = 0;
u32 total_size = 0; u32 total_size = 0;
path[0] = 0; path[0] = 0;