X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/39236c6e673c41db228275375ab7fdb0f837b292..5ba3f43ea354af8ad55bea84372a2bc834d8757c:/bsd/miscfs/devfs/devfs_fdesc_support.c diff --git a/bsd/miscfs/devfs/devfs_fdesc_support.c b/bsd/miscfs/devfs/devfs_fdesc_support.c index bf4e3bb06..5d9355efc 100644 --- a/bsd/miscfs/devfs/devfs_fdesc_support.c +++ b/bsd/miscfs/devfs/devfs_fdesc_support.c @@ -568,9 +568,15 @@ devfs_devfd_readdir(struct vnop_readdir_args *ap) if (ap->a_flags & (VNODE_READDIR_EXTENDED | VNODE_READDIR_REQSEEKOFF)) return (EINVAL); + /* + * There needs to be space for at least one entry. + */ + if (uio_resid(uio) < UIO_MX) + return (EINVAL); + i = uio->uio_offset / UIO_MX; error = 0; - while (uio_resid(uio) > 0) { + while (uio_resid(uio) >= UIO_MX) { if (i >= p->p_fd->fd_nfiles) break;