mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-02-13 03:31:06 +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); };
|
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) {
|
if (fseek(f, offset, SEEK_SET) != 0) {
|
||||||
return fsdevGetLastResult();
|
return fsdevGetLastResult();
|
||||||
}
|
}
|
||||||
|
@ -585,6 +593,14 @@ namespace sts::ncm {
|
||||||
fclose(f);
|
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) {
|
if (fseek(f, offset, SEEK_SET) != 0) {
|
||||||
return fsdevGetLastResult();
|
return fsdevGetLastResult();
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
/* We should be given a qualified path. */
|
/* We should be given a qualified path. */
|
||||||
if (!unqual_path || unqual_path > path + 0xf) {
|
if (!unqual_path || unqual_path > path + 0xf) {
|
||||||
return ResultFsUnqualifiedPath;
|
return ResultInvalidMountName;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(mount_name.name, path, unqual_path - path);
|
strncpy(mount_name.name, path, unqual_path - path);
|
||||||
|
|
|
@ -156,7 +156,9 @@ namespace sts::ncm {
|
||||||
static constexpr Result ResultNcmInvalidPlaceHolderDirectoryEntry = MAKERESULT(Module_Ncm, 170);
|
static constexpr Result ResultNcmInvalidPlaceHolderDirectoryEntry = MAKERESULT(Module_Ncm, 170);
|
||||||
static constexpr Result ResultNcmInvalidContentStorageOperation = MAKERESULT(Module_Ncm, 190);
|
static constexpr Result ResultNcmInvalidContentStorageOperation = MAKERESULT(Module_Ncm, 190);
|
||||||
static constexpr Result ResultNcmStorageRootNotFound = MAKERESULT(Module_Ncm, 310);
|
static constexpr Result ResultNcmStorageRootNotFound = MAKERESULT(Module_Ncm, 310);
|
||||||
static constexpr Result ResultFsUnqualifiedPath = MAKERESULT(Module_Fs, 6065);
|
|
||||||
|
static constexpr Result ResultFileExtensionWithoutOpenModeAllowAppend = MAKERESULT(Module_Fs, 6201);
|
||||||
|
static constexpr Result ResultInvalidMountName = MAKERESULT(Module_Fs, 6065);
|
||||||
static constexpr Result ResultFsMountNameNotFound = MAKERESULT(Module_Fs, 6905);
|
static constexpr Result ResultFsMountNameNotFound = MAKERESULT(Module_Fs, 6905);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue