Skip to content

Commit

Permalink
Tweak open() and sys_open() to return EFAULT error when pathname null
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed May 16, 2019
1 parent 9cb7e73 commit a0dcf85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/vfs/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions fs/vfs/vfs_syscalls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a0dcf85

Please sign in to comment.