mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
ro: bss size is allowed to be zero
This commit is contained in:
parent
889ea5e5aa
commit
b0cae74bb9
1 changed files with 10 additions and 3 deletions
|
@ -286,7 +286,7 @@ namespace ams::ro::impl {
|
|||
}
|
||||
}
|
||||
|
||||
constexpr inline Result ValidateAddressAndSize(u64 address, u64 size) {
|
||||
constexpr inline Result ValidateAddressAndNonZeroSize(u64 address, u64 size) {
|
||||
R_UNLESS(util::IsAligned(address, os::MemoryPageSize), ResultInvalidAddress());
|
||||
R_UNLESS(size != 0, ResultInvalidSize());
|
||||
R_UNLESS(util::IsAligned(size, os::MemoryPageSize), ResultInvalidSize());
|
||||
|
@ -294,6 +294,13 @@ namespace ams::ro::impl {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
constexpr inline Result ValidateAddressAndSize(u64 address, u64 size) {
|
||||
R_UNLESS(util::IsAligned(address, os::MemoryPageSize), ResultInvalidAddress());
|
||||
R_UNLESS(util::IsAligned(size, os::MemoryPageSize), ResultInvalidSize());
|
||||
R_UNLESS(size == 0 || address < address + size, ResultInvalidSize());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Access utilities. */
|
||||
|
@ -366,7 +373,7 @@ namespace ams::ro::impl {
|
|||
const ncm::ProgramId program_id = context->GetProgramId(process_h);
|
||||
|
||||
/* Validate address/size. */
|
||||
R_TRY(ValidateAddressAndSize(nrr_address, nrr_size));
|
||||
R_TRY(ValidateAddressAndNonZeroSize(nrr_address, nrr_size));
|
||||
|
||||
/* Check we have space for a new NRR. */
|
||||
NrrInfo *nrr_info = nullptr;
|
||||
|
@ -415,7 +422,7 @@ namespace ams::ro::impl {
|
|||
AMS_ASSERT(context != nullptr);
|
||||
|
||||
/* Validate address/size. */
|
||||
R_TRY(ValidateAddressAndSize(nro_address, nro_size));
|
||||
R_TRY(ValidateAddressAndNonZeroSize(nro_address, nro_size));
|
||||
R_TRY(ValidateAddressAndSize(bss_address, bss_size));
|
||||
|
||||
const u64 total_size = nro_size + bss_size;
|
||||
|
|
Loading…
Reference in a new issue