Skip to content

Commit

Permalink
nn_save: Fix inverted condition preventing accessing other title's saves
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzap committed May 5, 2024
1 parent 70afe3a commit dd3ed56
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Cafe/OS/libs/nn_save/nn_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ namespace save
return false;
}

SAVEStatus GetAbsoluteFullPathOtherApplication(uint32 persistentId, uint64 titleId, const char* subDir, char* outPath)
FS_RESULT GetAbsoluteFullPathOtherApplication(uint32 persistentId, uint64 titleId, const char* subDir, char* outPath)
{
uint32be applicationBox;
if(acp::ACPGetApplicationBox(&applicationBox, titleId) != acp::ACPStatus::SUCCESS)
return (FSStatus)FS_RESULT::NOT_FOUND;
return FS_RESULT::NOT_FOUND;

sint32 written = 0;
if(applicationBox == 3)
Expand Down Expand Up @@ -151,13 +151,13 @@ namespace save
cemu_assert_unimplemented();
}
else
return (FSStatus)FS_RESULT::NOT_FOUND;
return FS_RESULT::NOT_FOUND;

if (written < SAVE_MAX_PATH_SIZE - 1)
return (FSStatus)FS_RESULT::SUCCESS;
return FS_RESULT::SUCCESS;

cemu_assert_suspicious();
return (FSStatus)(FS_RESULT::FATAL_ERROR);
return FS_RESULT::FATAL_ERROR;
}

typedef struct
Expand Down Expand Up @@ -417,7 +417,7 @@ namespace save
if (GetPersistentIdEx(accountSlot, &persistentId))
{
char fullPath[SAVE_MAX_PATH_SIZE];
if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath))
if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS)
result = coreinit::FSOpenFileAsync(client, block, fullPath, (char*)mode, outFileHandle, errHandling, (FSAsyncParams*)asyncParams);
}
else
Expand Down Expand Up @@ -527,7 +527,7 @@ namespace save
if (GetPersistentIdEx(accountSlot, &persistentId))
{
char fullPath[SAVE_MAX_PATH_SIZE];
if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == (FSStatus)FS_RESULT::SUCCESS)
if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS)
result = coreinit::__FSQueryInfoAsync(client, block, (uint8*)fullPath, FSA_QUERY_TYPE_STAT, stat, errHandling, (FSAsyncParams*)asyncParams); // FSGetStatAsync(...)
}
else
Expand Down Expand Up @@ -811,7 +811,7 @@ namespace save
if (GetPersistentIdEx(accountSlot, &persistentId))
{
char fullPath[SAVE_MAX_PATH_SIZE];
if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath))
if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS)
result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParams*)asyncParams);
}
else
Expand Down

0 comments on commit dd3ed56

Please sign in to comment.