From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Waldemar Kozaczuk <jwkozac...@gmail.com>
Branch: master
Tweak open() and sys_open() to return EFAULT error when pathname null
Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
diff --git a/fs/vfs/main.cc b/fs/vfs/main.cc
--- a/fs/vfs/main.cc
+++ b/fs/vfs/main.cc
@@ -120,6 +120,11 @@ int open(const char *pathname, int flags, ...)
int fd, error;
int acc;
+ if (pathname == nullptr) {
+ error = EFAULT;
+ goto out_errno;
+ }
+
acc = 0;
switch (flags & O_ACCMODE) {
case O_RDONLY:
diff --git a/fs/vfs/vfs_syscalls.cc b/fs/vfs/vfs_syscalls.cc
--- a/fs/vfs/vfs_syscalls.cc
+++ b/fs/vfs/vfs_syscalls.cc
@@ -117,6 +117,10 @@ sys_open(char *path, int flags, mode_t mode, struct
file **fpp)
DPRINTF(VFSDB_SYSCALL, ("sys_open: path=%s flags=%x mode=%x\n",
path, flags, mode));
+ if (path == nullptr) {
+ return (EFAULT);
+ }
+
flags = fflags(flags);
if (flags & O_CREAT) {
error = namei(path, &dp);
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/osv-dev/00000000000046adab05890bc006%40google.com.
For more options, visit https://groups.google.com/d/optout.