mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:08:12 +00:00
Kernel: When validating a string read, validate the pointer first.
Calling strlen() on an invalid pointer is just gonna crash the process.
This commit is contained in:
parent
887b4a7a1a
commit
f4bce03716
2 changed files with 8 additions and 1 deletions
|
@ -1643,6 +1643,13 @@ bool Process::validate_read_from_kernel(LinearAddress laddr) const
|
|||
return validate_read(laddr.as_ptr(), 1);
|
||||
}
|
||||
|
||||
bool Process::validate_read_str(const char* str)
|
||||
{
|
||||
if (!validate_read(str, 1))
|
||||
return false;
|
||||
return validate_read(str, strlen(str) + 1);
|
||||
}
|
||||
|
||||
bool Process::validate_read(const void* address, size_t size) const
|
||||
{
|
||||
if (is_ring0()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue