1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

Kernel: mkdir() should fail if the pathname is empty.

This commit is contained in:
Andreas Kling 2019-02-01 15:24:42 +01:00
parent 240b5fe677
commit 33e7df5955

View file

@ -1863,10 +1863,13 @@ int Process::sys$mkdir(const char* pathname, mode_t mode)
{ {
if (!validate_read_str(pathname)) if (!validate_read_str(pathname))
return -EFAULT; return -EFAULT;
if (strlen(pathname) >= 255) size_t pathname_length = strlen(pathname);
if (pathname_length == 0)
return -EINVAL;
if (pathname_length >= 255)
return -ENAMETOOLONG; return -ENAMETOOLONG;
int error; int error;
if (!VFS::the().mkdir(pathname, mode, cwd_inode()->identifier(), error)) if (!VFS::the().mkdir(String(pathname, pathname_length), mode, cwd_inode()->identifier(), error))
return error; return error;
return 0; return 0;
} }