From f44472fd0a237655c5527c24fb568b83f992de45 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Tue, 15 Mar 2016 16:25:48 +0100 Subject: [PATCH] Also check write permissions for creating folders / renaming files Plus: Don't allow renaming virtual FAT entries --- source/fs.c | 2 ++ source/godmode.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/fs.c b/source/fs.c index a2c9a54..9d092aa 100644 --- a/source/fs.c +++ b/source/fs.c @@ -291,6 +291,7 @@ bool PathDelete(const char* path) { bool PathRename(const char* path, const char* newname) { char npath[256]; // 256 is the maximum length of a full path char* oldname = strrchr(path, '/'); + if (!CheckWritePermissions(path)) return false; if (!oldname) return false; oldname++; strncpy(npath, path, oldname - path); @@ -300,6 +301,7 @@ bool PathRename(const char* path, const char* newname) { 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 (f_mkdir(npath) == FR_OK); } diff --git a/source/godmode.c b/source/godmode.c index 0f8abcc..cf28e34 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -270,7 +270,7 @@ u32 GodMode() { ClearScreenF(true, false, COLOR_STD_BG); } } else { // switched command set - if (pad_state & BUTTON_X) { // rename a file + if ((pad_state & BUTTON_X) && cursor) { // rename a file char newname[256]; char namestr[20+1]; TruncateString(namestr, current_dir->entry[cursor].name, 20, 12);