mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-18 01:46:47 +00:00
kern: add bounds checking to KHandleTable::Register/Unreserve
This commit is contained in:
parent
44ccbc2a7b
commit
01f5c89902
1 changed files with 14 additions and 12 deletions
|
@ -120,9 +120,9 @@ namespace ams::kern {
|
||||||
const auto reserved = handle_pack.Get<HandleReserved>();
|
const auto reserved = handle_pack.Get<HandleReserved>();
|
||||||
MESOSPHERE_ASSERT(reserved == 0);
|
MESOSPHERE_ASSERT(reserved == 0);
|
||||||
MESOSPHERE_ASSERT(linear_id != 0);
|
MESOSPHERE_ASSERT(linear_id != 0);
|
||||||
MESOSPHERE_ASSERT(index < m_table_size);
|
|
||||||
MESOSPHERE_UNUSED(linear_id, reserved);
|
MESOSPHERE_UNUSED(linear_id, reserved);
|
||||||
|
|
||||||
|
if (index < m_table_size) {
|
||||||
/* Free the entry. */
|
/* Free the entry. */
|
||||||
/* NOTE: This code does not check the linear id. */
|
/* NOTE: This code does not check the linear id. */
|
||||||
Entry *entry = std::addressof(m_table[index]);
|
Entry *entry = std::addressof(m_table[index]);
|
||||||
|
@ -130,6 +130,7 @@ namespace ams::kern {
|
||||||
|
|
||||||
this->FreeEntry(entry);
|
this->FreeEntry(entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KHandleTable::Register(ams::svc::Handle handle, KAutoObject *obj, u16 type) {
|
void KHandleTable::Register(ams::svc::Handle handle, KAutoObject *obj, u16 type) {
|
||||||
MESOSPHERE_ASSERT_THIS();
|
MESOSPHERE_ASSERT_THIS();
|
||||||
|
@ -143,9 +144,9 @@ namespace ams::kern {
|
||||||
const auto reserved = handle_pack.Get<HandleReserved>();
|
const auto reserved = handle_pack.Get<HandleReserved>();
|
||||||
MESOSPHERE_ASSERT(reserved == 0);
|
MESOSPHERE_ASSERT(reserved == 0);
|
||||||
MESOSPHERE_ASSERT(linear_id != 0);
|
MESOSPHERE_ASSERT(linear_id != 0);
|
||||||
MESOSPHERE_ASSERT(index < m_table_size);
|
|
||||||
MESOSPHERE_UNUSED(reserved);
|
MESOSPHERE_UNUSED(reserved);
|
||||||
|
|
||||||
|
if (index < m_table_size) {
|
||||||
/* Set the entry. */
|
/* Set the entry. */
|
||||||
Entry *entry = std::addressof(m_table[index]);
|
Entry *entry = std::addressof(m_table[index]);
|
||||||
MESOSPHERE_ASSERT(entry->GetObject() == nullptr);
|
MESOSPHERE_ASSERT(entry->GetObject() == nullptr);
|
||||||
|
@ -153,5 +154,6 @@ namespace ams::kern {
|
||||||
entry->SetUsed(obj, linear_id, type);
|
entry->SetUsed(obj, linear_id, type);
|
||||||
obj->Open();
|
obj->Open();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue