From 6a04bfca672f006d6fea3767deeea554469d969f Mon Sep 17 00:00:00 2001 From: d0k3 Date: Wed, 18 Jul 2018 00:16:41 +0200 Subject: [PATCH] Safety checks for dummy file / dir creation --- arm9/source/filesys/fsutil.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arm9/source/filesys/fsutil.c b/arm9/source/filesys/fsutil.c index d9741e0..a33a952 100644 --- a/arm9/source/filesys/fsutil.c +++ b/arm9/source/filesys/fsutil.c @@ -367,14 +367,15 @@ bool FileCreateDummy(const char* cpath, const char* filename, u64 size) { f_sync(&dfile); fx_close(&dfile); - return true; + return (fa_stat(npath, NULL) == FR_OK); } bool DirCreate(const char* cpath, const char* dirname) { char npath[256]; // 256 is the maximum length of a full path if (!CheckWritePermissions(cpath)) return false; snprintf(npath, 255, "%s/%s", cpath, dirname); - return (fa_mkdir(npath) == FR_OK); + if (fa_mkdir(npath) != FR_OK) return false; + return (fa_stat(npath, NULL) == FR_OK); } bool DirInfoWorker(char* fpath, bool virtual, u64* tsize, u32* tdirs, u32* tfiles) {