Kernel: Don't allow chdir into non-directories

This commit is contained in:
Bananymous 2026-03-17 22:57:17 +02:00
parent 43e18148a6
commit cdc45935b5
1 changed files with 2 additions and 0 deletions

View File

@ -2380,6 +2380,8 @@ namespace Kernel
TRY(read_string_from_user(user_path, path, PATH_MAX)); TRY(read_string_from_user(user_path, path, PATH_MAX));
auto new_cwd = TRY(find_file(AT_FDCWD, path, O_SEARCH)); auto new_cwd = TRY(find_file(AT_FDCWD, path, O_SEARCH));
if (!new_cwd.inode->mode().ifdir())
return BAN::Error::from_errno(ENOTDIR);
LockGuard _(m_process_lock); LockGuard _(m_process_lock);
m_working_directory = BAN::move(new_cwd); m_working_directory = BAN::move(new_cwd);