From 0dbe1264267308ee097b396f99ae00236e5b0089 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Sat, 17 Aug 2019 06:33:50 -0400 Subject: [PATCH] Two quick fixes. * Fixed segmentation fault on NSP dumping, produced by a change I forgot to revert while testing some stuff. * Fixed a bug that made file splitting not take place while manually dumping a file bigger than 4 GiB from the RomFS section of any title. --- README.md | 1 + source/dumper.c | 19 ++++++++++++------- source/util.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3c13ea6..627270b 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Changelog **v1.1.4:** * Fixed building with latest libnx release. * Optimized RomFS recursive file dump function to not rely on code recursion as much as before, avoiding stack memory exhaustion problems. Fixes crashes while dumping RomFS data from games with lots of file entries. +* Fixed a bug that made file splitting not take place while manually dumping a file bigger than 4 GiB from the RomFS section of any title. * Reduced max part size for split files to `0xFFFF0000` bytes in all operations (except for XCI dumps when the "Create directory with archive bit set" option is disabled). Fixes file access problems if the parts are used inside a directory with the archive bit set. * Removed the `removeDirectory()` function. `fsdevDeleteDirectoryRecursively()` is now used instead. * If a HFS0/ExeFS/RomFS data dump operation is cancelled or fails, a message telling the user to wait until the output directory is fully deleted will now be displayed. diff --git a/source/dumper.c b/source/dumper.c index 095a485..752112d 100644 --- a/source/dumper.c +++ b/source/dumper.c @@ -4472,12 +4472,6 @@ bool dumpFileFromRomFsSection(u32 titleIndex, u32 file_offset, bool usePatch, bo strncat(dumpPath, (char*)entry->name, entry->nameLen); removeIllegalCharacters(dumpPath + cur_len); - if (progressCtx.totalSize > FAT32_FILESIZE_LIMIT && doSplitting) - { - sprintf(tmp_idx, ".%02u", splitIndex); - strcat(dumpPath, tmp_idx); - } - progressCtx.totalSize = entry->dataSize; convertSize(progressCtx.totalSize, progressCtx.totalSizeStr, sizeof(progressCtx.totalSizeStr) / sizeof(progressCtx.totalSizeStr[0])); @@ -4493,6 +4487,12 @@ bool dumpFileFromRomFsSection(u32 titleIndex, u32 file_offset, bool usePatch, bo breaks++; + if (progressCtx.totalSize > FAT32_FILESIZE_LIMIT && doSplitting) + { + sprintf(tmp_idx, ".%02u", splitIndex); + strcat(dumpPath, tmp_idx); + } + // Check if the dump already exists if (checkIfFileExists(dumpPath)) { @@ -4523,7 +4523,12 @@ bool dumpFileFromRomFsSection(u32 titleIndex, u32 file_offset, bool usePatch, bo } // Start dump process - snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Copying \"romfs:%s/%.*s\"...", curRomFsPath, entry->nameLen, entry->name); + if (strlen(curRomFsPath) > 1) + { + snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Copying \"romfs:%s/%.*s\"...", curRomFsPath, entry->nameLen, entry->name); + } else { + snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Copying \"romfs:/%.*s\"...", entry->nameLen, entry->name); + } uiDrawString(strbuf, 8, (breaks * (font_height + (font_height / 4))) + (font_height / 8), 255, 255, 255); breaks += 2; diff --git a/source/util.h b/source/util.h index 632335b..0e817d3 100644 --- a/source/util.h +++ b/source/util.h @@ -18,7 +18,7 @@ #define MiB (1024.0 * KiB) #define GiB (1024.0 * MiB) -#define NAME_BUF_LEN 1024 +#define NAME_BUF_LEN 4096 #define SOCK_BUFFERSIZE 65536