Skip to content

Commit

Permalink
fuse: readdir: check for slash in names
Browse files Browse the repository at this point in the history
Userspace can add names containing a slash character to the directory
listing.  Don't allow this as it could cause all sorts of trouble.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: stable@vger.kernel.org
  • Loading branch information
Miklos Szeredi committed Sep 3, 2013
1 parent 06a7c3c commit efeb9e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,8 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file,
return -EIO;
if (reclen > nbytes)
break;
if (memchr(dirent->name, '/', dirent->namelen) != NULL)
return -EIO;

if (!dir_emit(ctx, dirent->name, dirent->namelen,
dirent->ino, dirent->type))
Expand Down Expand Up @@ -1320,6 +1322,8 @@ static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
return -EIO;
if (reclen > nbytes)
break;
if (memchr(dirent->name, '/', dirent->namelen) != NULL)
return -EIO;

if (!over) {
/* We fill entries into dstbuf only as much as
Expand Down

0 comments on commit efeb9e6

Please sign in to comment.