Fix case sensitive permission checks

This commit is contained in:
d0k3 2017-07-27 20:30:07 +02:00
parent 5f70cdc8fa
commit 3da6cf5c0e

View File

@ -34,11 +34,11 @@ bool CheckWritePermissions(const char* path) {
const char* path_lvl2[] = { PATH_SYS_LVL2 }; const char* path_lvl2[] = { PATH_SYS_LVL2 };
const char* path_lvl1[] = { PATH_SYS_LVL1 }; const char* path_lvl1[] = { PATH_SYS_LVL1 };
for (u32 i = 0; (i < sizeof(path_lvl3) / sizeof(char*)) && (lvl < 3); i++) for (u32 i = 0; (i < sizeof(path_lvl3) / sizeof(char*)) && (lvl < 3); i++)
if (strncmp(path, path_lvl3[i], 256) == 0) lvl = 3; if (strncasecmp(path, path_lvl3[i], 256) == 0) lvl = 3;
for (u32 i = 0; (i < sizeof(path_lvl2) / sizeof(char*)) && (lvl < 2); i++) for (u32 i = 0; (i < sizeof(path_lvl2) / sizeof(char*)) && (lvl < 2); i++)
if (strncmp(path, path_lvl2[i], 256) == 0) lvl = 2; if (strncasecmp(path, path_lvl2[i], 256) == 0) lvl = 2;
for (u32 i = 0; (i < sizeof(path_lvl1) / sizeof(char*)) && (lvl < 1); i++) for (u32 i = 0; (i < sizeof(path_lvl1) / sizeof(char*)) && (lvl < 1); i++)
if (strncmp(path, path_lvl1[i], 256) == 0) lvl = 1; if (strncasecmp(path, path_lvl1[i], 256) == 0) lvl = 1;
} }
if (!IS_A9LH) { // changed SysNAND permission levels on non-A9LH if (!IS_A9LH) { // changed SysNAND permission levels on non-A9LH
if ((drvtype & DRV_CTRNAND) || (lvl == 2)) lvl = 3; if ((drvtype & DRV_CTRNAND) || (lvl == 2)) lvl = 3;
@ -51,7 +51,7 @@ bool CheckWritePermissions(const char* path) {
if (drvtype & DRV_VIRTUAL) { // check for paths if (drvtype & DRV_VIRTUAL) { // check for paths
const char* path_lvl1[] = { PATH_EMU_LVL1 }; const char* path_lvl1[] = { PATH_EMU_LVL1 };
for (u32 i = 0; (i < sizeof(path_lvl1) / sizeof(char*)) && (lvl < 1); i++) for (u32 i = 0; (i < sizeof(path_lvl1) / sizeof(char*)) && (lvl < 1); i++)
if (strncmp(path, path_lvl1[i], 256) == 0) lvl = 1; if (strncasecmp(path, path_lvl1[i], 256) == 0) lvl = 1;
} }
perm = perms[lvl]; perm = perms[lvl];
snprintf(area_name, 16, "EmuNAND (lvl%lu)", lvl); snprintf(area_name, 16, "EmuNAND (lvl%lu)", lvl);
@ -70,7 +70,7 @@ bool CheckWritePermissions(const char* path) {
} else if (drvtype & DRV_MEMORY) { } else if (drvtype & DRV_MEMORY) {
perm = PERM_MEMORY; perm = PERM_MEMORY;
snprintf(area_name, 16, "memory areas"); snprintf(area_name, 16, "memory areas");
} else if (strncmp(path, "0:/Nintendo 3DS", 15) == 0) { // this check could be better } else if (strncasecmp(path, "0:/Nintendo 3DS", 15) == 0) { // this check could be better
perm = PERM_SDDATA; perm = PERM_SDDATA;
snprintf(area_name, 16, "SD system data"); snprintf(area_name, 16, "SD system data");
} else if (drvtype & DRV_SDCARD) { } else if (drvtype & DRV_SDCARD) {