Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion fs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ int_t sys_getdents_common(fd_t f, addr_t dirents, dword_t count,
printed++;
}

if (reclen > count)
if (reclen > count) {
if (count == orig_count) {
// If the buffer isn't large enough to read even a single dirent,
// reset the fd and return _EINVAL.
fd_seekdir(fd, ptr);
return _EINVAL;
}
break;
}
if (user_write(dirents, dirent_data, reclen))
return _EFAULT;
dirents += reclen;
Expand Down
Loading