Skip to content

Commit a0dcf85

Browse files
committed
Tweak open() and sys_open() to return EFAULT error when pathname null
Signed-off-by: Waldemar Kozaczuk <[email protected]>
1 parent 9cb7e73 commit a0dcf85

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fs/vfs/main.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ int open(const char *pathname, int flags, ...)
120120
int fd, error;
121121
int acc;
122122

123+
if (pathname == nullptr) {
124+
error = EFAULT;
125+
goto out_errno;
126+
}
127+
123128
acc = 0;
124129
switch (flags & O_ACCMODE) {
125130
case O_RDONLY:

fs/vfs/vfs_syscalls.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ sys_open(char *path, int flags, mode_t mode, struct file **fpp)
117117
DPRINTF(VFSDB_SYSCALL, ("sys_open: path=%s flags=%x mode=%x\n",
118118
path, flags, mode));
119119

120+
if (path == nullptr) {
121+
return (EFAULT);
122+
}
123+
120124
flags = fflags(flags);
121125
if (flags & O_CREAT) {
122126
error = namei(path, &dp);

0 commit comments

Comments
 (0)