1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-22 11:56:40 +00:00

ro: bss size is allowed to be zero

This commit is contained in:
Michael Scire 2019-12-07 18:13:16 -08:00
parent 889ea5e5aa
commit b0cae74bb9

View file

@ -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;