Manually prevent placeholder/content appending

This commit is contained in:
Adubbz
2019-08-06 21:29:28 +10:00
parent 7bcf2276a7
commit 5e0f4130c4
3 changed files with 25 additions and 7 deletions

View File

@@ -157,6 +157,14 @@ namespace sts::ncm {
auto file_guard = SCOPE_GUARD { fclose(f); };
u64 size = 0;
R_TRY(GetSizeFromPlaceHolderId(&size, placeholder_id));
/* We can't disable append with stdio, so check this manually. */
if (offset + data.num_elements > size) {
return ResultFileExtensionWithoutOpenModeAllowAppend;
}
if (fseek(f, offset, SEEK_SET) != 0) {
return fsdevGetLastResult();
}
@@ -585,6 +593,14 @@ namespace sts::ncm {
fclose(f);
};
u64 size = 0;
R_TRY(GetSizeFromContentId(&size, content_id));
/* We can't disable append with stdio, so check this manually. */
if (offset + data.num_elements > size) {
return ResultFileExtensionWithoutOpenModeAllowAppend;
}
if (fseek(f, offset, SEEK_SET) != 0) {
return fsdevGetLastResult();
}