mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibC: Make the syscall wrappers for stat/lstat/chdir return EFAULT
If we pass a null path to these syscall wrappers, just return EFAULT directly from the wrapper instead of segfaulting by calling strlen(). This is a compromise, since we now have to pass the path length to the kernel, so we can't rely on the kernel to tell us that the path is at a bad memory address.
This commit is contained in:
parent
642137f014
commit
53d3b6b0a7
Notes:
sideshowbarker
2024-07-19 10:19:02 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/53d3b6b0a70
1 changed files with 12 additions and 0 deletions
|
@ -227,12 +227,20 @@ pid_t waitpid(pid_t waitee, int* wstatus, int options)
|
|||
|
||||
int lstat(const char* path, struct stat* statbuf)
|
||||
{
|
||||
if (!path) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
int rc = syscall(SC_lstat, path, strlen(path), statbuf);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int stat(const char* path, struct stat* statbuf)
|
||||
{
|
||||
if (!path) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
int rc = syscall(SC_stat, path, strlen(path), statbuf);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
@ -245,6 +253,10 @@ int fstat(int fd, struct stat* statbuf)
|
|||
|
||||
int chdir(const char* path)
|
||||
{
|
||||
if (!path) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
int rc = syscall(SC_chdir, path, strlen(path));
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue