From 28ebdc213eff96e671a3df04e4482d8707eea778 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 18 Jan 2026 21:01:54 +0200 Subject: [PATCH] nyx: handle exFAT truncation in stat/backup It's possible for the overflow check to fail if exFAT and file size is big enough. (4GB + total_size) So check it properly. This avoids unnecessary copying before RAM disk gets filled and copy errors out. No other check is needed since max capacity is RAM disk size. --- nyx/nyx_gui/frontend/gui_tools_partition_manager.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c index 837fee75..7c475654 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -196,10 +196,10 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3 // Copy file to destination disk. if (!(fno.fattrib & AM_DIR)) { - u32 file_size = fno.fsize > RAMDISK_CLUSTER_SZ ? fno.fsize : RAMDISK_CLUSTER_SZ; // Ramdisk cluster size. + u64 file_size = fno.fsize > RAMDISK_CLUSTER_SZ ? fno.fsize : RAMDISK_CLUSTER_SZ; - // Check for overflow. - if ((file_size + *total_size) < *total_size) + // Check for FAT32 or total overflow. + if ((file_size + *total_size) > 0xFFFFFFFFu) { // Set size to > 1GB, skip next folders and return. *total_size = SZ_2G; @@ -207,9 +207,10 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3 break; } - *total_size += file_size; + *total_size += file_size; *total_files += 1; + // Create a copy to destination. if (dst) { FIL fp_src;