Scripting: improved write permission checks

This commit is contained in:
d0k3 2017-09-08 20:58:20 +02:00
parent 322c996afe
commit 77ed3d4733
2 changed files with 3 additions and 1 deletions

View File

@ -1386,6 +1386,7 @@ u32 DumpCxiSrlFromTmdFile(const char* path) {
// prepare output name
snprintf(dest, 256, OUTPUT_PATH "/");
char* dname = dest + strnlen(dest, 256);
if (!CheckWritePermissions(dest)) return 1;
// ensure the output dir exists
if (fvx_rmkdir(OUTPUT_PATH) != FR_OK)
@ -1426,6 +1427,7 @@ u32 ExtractCodeFromCxiFile(const char* path, const char* path_out) {
if (fvx_rmkdir(OUTPUT_PATH) != FR_OK) return 1;
snprintf(dest, 256, OUTPUT_PATH "/%016llX%s%s", ncch.programId, (exthdr.flag & 0x1) ? ".dec" : "", EXEFS_CODE_NAME);
} else strncpy(dest, path_out, 256);
if (!CheckWritePermissions(dest)) return 1;
// write output file
fvx_unlink(dest);

View File

@ -527,7 +527,7 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) {
ret = PathDelete(argv[0]);
if (err_str) snprintf(err_str, _ERR_STR_LEN, "remove fail");
} else if (id == CMD_ID_MKDIR) {
ret = (fvx_rmkdir(argv[0]) == FR_OK);
ret = (CheckWritePermissions(argv[0])) && (fvx_rmkdir(argv[0]) == FR_OK);
if (err_str) snprintf(err_str, _ERR_STR_LEN, "makedir fail");
} else if (id == CMD_ID_MOUNT) {
ret = InitImgFS(argv[0]);