Skip to content

Commit

Permalink
vfs: Harden task_conv() to return EFAULT when cpath argument is null
Browse files Browse the repository at this point in the history
This patch also reverts the commit a0dcf85.

Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com>
Message-Id: <20190519204728.16752-1-jwkozaczuk@gmail.com>
  • Loading branch information
wkozaczuk authored and nyh committed May 20, 2019
1 parent edcf259 commit 7bc0155
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 0 additions & 5 deletions fs/vfs/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ 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: 0 additions & 4 deletions fs/vfs/vfs_syscalls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ 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
4 changes: 4 additions & 0 deletions fs/vfs/vfs_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ task_conv(struct task *t, const char *cpath, int acc, char *full)
{
int rc;

if (cpath == nullptr) {
return (EFAULT);
}

rc = path_conv(t->t_cwd, cpath, full);
if (rc != 0) {
return (rc);
Expand Down

0 comments on commit 7bc0155

Please sign in to comment.