mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-02-12 19:21:14 +00:00
Manually prevent placeholder/content appending
This commit is contained in:
parent
7bcf2276a7
commit
5e0f4130c4
3 changed files with 25 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ namespace sts::ncm {
|
|||
|
||||
/* We should be given a qualified path. */
|
||||
if (!unqual_path || unqual_path > path + 0xf) {
|
||||
return ResultFsUnqualifiedPath;
|
||||
return ResultInvalidMountName;
|
||||
}
|
||||
|
||||
strncpy(mount_name.name, path, unqual_path - path);
|
||||
|
|
|
@ -152,11 +152,13 @@ namespace sts::ncm {
|
|||
typedef void (*MakePlaceHolderPathFunc)(char* out, PlaceHolderId placeholder_id, const char* root);
|
||||
|
||||
// TODO: Move to libstrat
|
||||
static constexpr Result ResultNcmStoragePathNotFound = MAKERESULT(Module_Ncm, 1);
|
||||
static constexpr Result ResultNcmInvalidPlaceHolderDirectoryEntry = MAKERESULT(Module_Ncm, 170);
|
||||
static constexpr Result ResultNcmInvalidContentStorageOperation = MAKERESULT(Module_Ncm, 190);
|
||||
static constexpr Result ResultNcmStorageRootNotFound = MAKERESULT(Module_Ncm, 310);
|
||||
static constexpr Result ResultFsUnqualifiedPath = MAKERESULT(Module_Fs, 6065);
|
||||
static constexpr Result ResultFsMountNameNotFound = MAKERESULT(Module_Fs, 6905);
|
||||
static constexpr Result ResultNcmStoragePathNotFound = MAKERESULT(Module_Ncm, 1);
|
||||
static constexpr Result ResultNcmInvalidPlaceHolderDirectoryEntry = MAKERESULT(Module_Ncm, 170);
|
||||
static constexpr Result ResultNcmInvalidContentStorageOperation = MAKERESULT(Module_Ncm, 190);
|
||||
static constexpr Result ResultNcmStorageRootNotFound = MAKERESULT(Module_Ncm, 310);
|
||||
|
||||
static constexpr Result ResultFileExtensionWithoutOpenModeAllowAppend = MAKERESULT(Module_Fs, 6201);
|
||||
static constexpr Result ResultInvalidMountName = MAKERESULT(Module_Fs, 6065);
|
||||
static constexpr Result ResultFsMountNameNotFound = MAKERESULT(Module_Fs, 6905);
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue