summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-01 15:24:42 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-01 15:29:05 +0100
commit33e7df595505d0b52eab633ab5503b2318ee1461 (patch)
tree9c07d7f10f37d14f413697fcdebcf02036313e5e
parent240b5fe677109e1cdc6fb964a6fb49750303f305 (diff)
downloadserenity-33e7df595505d0b52eab633ab5503b2318ee1461.zip
Kernel: mkdir() should fail if the pathname is empty.
-rw-r--r--Kernel/Process.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 901c16f711..6c5745530c 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -1863,10 +1863,13 @@ int Process::sys$mkdir(const char* pathname, mode_t mode)
{
if (!validate_read_str(pathname))
return -EFAULT;
- if (strlen(pathname) >= 255)
+ size_t pathname_length = strlen(pathname);
+ if (pathname_length == 0)
+ return -EINVAL;
+ if (pathname_length >= 255)
return -ENAMETOOLONG;
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 0;
}