From 33e7df595505d0b52eab633ab5503b2318ee1461 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 1 Feb 2019 15:24:42 +0100 Subject: Kernel: mkdir() should fail if the pathname is empty. --- Kernel/Process.cpp | 7 +++++-- 1 file 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; } -- cgit v1.2.3