Skip to content

Commit c994b80

Browse files
committed
Handle a few more cellSaveData errors
* Check directory existence if setParam is NULL (dont create directory) * Fix mask for reCreateMode * Check a few setParam fields including reserved buffers. * Fix sizeKb when the dir is empty except from PARAM.SFO * Fix error checking when CELL_SAVEDATA_RECREATE_YES is specified but setParam is NULL (Doesnt do anything, simply errors)
1 parent a419415 commit c994b80

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

rpcs3/Emu/Cell/Modules/cellSaveData.cpp

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
767767
}
768768

769769
statGet->sysSizeKB = 35; // always reported as 35 regardless of actual file sizes
770-
statGet->sizeKB = size_kbytes ? size_kbytes + statGet->sysSizeKB : 0;
770+
statGet->sizeKB = !save_entry.isNew ? size_kbytes + statGet->sysSizeKB : 0;
771771

772772
// Stat Callback
773773
funcStat(ppu, result, statGet, statSet);
@@ -797,6 +797,30 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
797797

798798
if (statSet->setParam)
799799
{
800+
if (statSet->setParam->attribute > CELL_SAVEDATA_ATTR_NODUPLICATE)
801+
{
802+
// ****** sysutil savedata parameter error : 57 ******
803+
return CELL_SAVEDATA_ERROR_PARAM;
804+
}
805+
806+
for (u8 resv : statSet->setParam->reserved2)
807+
{
808+
if (resv)
809+
{
810+
// ****** sysutil savedata parameter error : 58 ******
811+
return CELL_SAVEDATA_ERROR_PARAM;
812+
}
813+
}
814+
815+
for (u8 resv : statSet->setParam->reserved)
816+
{
817+
if (resv)
818+
{
819+
// ****** sysutil savedata parameter error : 59 ******
820+
return CELL_SAVEDATA_ERROR_PARAM;
821+
}
822+
}
823+
800824
// Update PARAM.SFO
801825
psf.clear();
802826
psf.insert(
@@ -816,14 +840,13 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
816840

817841
has_modified = true;
818842
}
819-
//else if (psf.empty())
820-
//{
821-
// // setParam is specified if something required updating.
822-
// // Do not exit. Recreate mode will handle the rest
823-
// //return CELL_OK;
824-
//}
825-
826-
switch (const u32 mode = statSet->reCreateMode & 0xffff)
843+
else if (save_entry.isNew)
844+
{
845+
// ****** sysutil savedata parameter error : 50 ******
846+
return CELL_SAVEDATA_ERROR_PARAM;
847+
}
848+
849+
switch (const u32 mode = statSet->reCreateMode & CELL_SAVEDATA_RECREATE_MASK)
827850
{
828851
case CELL_SAVEDATA_RECREATE_NO:
829852
{
@@ -841,6 +864,11 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
841864
case CELL_SAVEDATA_RECREATE_YES:
842865
case CELL_SAVEDATA_RECREATE_YES_RESET_OWNER:
843866
{
867+
if (!statSet->setParam)
868+
{
869+
// ****** sysutil savedata parameter error : 50 ******
870+
return CELL_SAVEDATA_ERROR_PARAM;
871+
}
844872

845873
// TODO: Only delete data, not owner info
846874
for (const auto& entry : fs::dir(dir_path))
@@ -851,15 +879,6 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
851879
}
852880
}
853881

854-
//TODO: probably not deleting owner info
855-
if (!statSet->setParam)
856-
{
857-
// Savedata deleted and setParam is NULL: delete directory and abort operation
858-
if (fs::remove_dir(dir_path)) cellSaveData.error("savedata_op(): savedata directory %s deleted", save_entry.dirName);
859-
860-
//return CELL_OK;
861-
}
862-
863882
break;
864883
}
865884

rpcs3/Emu/Cell/Modules/cellSaveData.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,16 @@ enum
8686
CELL_SAVEDATA_FILETYPE_CONTENT_PIC1 = 4,
8787
CELL_SAVEDATA_FILETYPE_CONTENT_SND0 = 5,
8888

89+
// CellSaveDataSystemFileParam attribute
90+
CELL_SAVEDATA_ATTR_NORMAL = 0,
91+
CELL_SAVEDATA_ATTR_NODUPLICATE = 1,
92+
8993
// reCreateMode
9094
CELL_SAVEDATA_RECREATE_NO = 0,
9195
CELL_SAVEDATA_RECREATE_NO_NOBROKEN = 1,
9296
CELL_SAVEDATA_RECREATE_YES = 2,
9397
CELL_SAVEDATA_RECREATE_YES_RESET_OWNER = 3,
94-
CELL_SAVEDATA_RECREATE_MASK = 0xffff,
98+
CELL_SAVEDATA_RECREATE_MASK = 0xfffeffff,
9599

96100
// Version
97101
CELL_SAVEDATA_VERSION_OLD = 0,

0 commit comments

Comments
 (0)