Date: Thu, 20 Jan 2011 09:39:16 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r217633 - head/sys/fs/tmpfs Message-ID: <201101200939.p0K9dGXm008098@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Thu Jan 20 09:39:16 2011 New Revision: 217633 URL: http://svn.freebsd.org/changeset/base/217633 Log: In tmpfs_readdir(), normalize handling of the directory entries that either overflow the supplied buffer, or cause uiomove fail. Do not advance cached de when directory entry was not copied out. Do not return EOF when no entries could be copied due to first entry too large for supplied buffer, signal EINVAL instead. Reported by: Beat G?tzi <beat chruetertee ch> MFC after: 1 week Modified: head/sys/fs/tmpfs/tmpfs_subr.c head/sys/fs/tmpfs/tmpfs_vnops.c Modified: head/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_subr.c Thu Jan 20 09:37:53 2011 (r217632) +++ head/sys/fs/tmpfs/tmpfs_subr.c Thu Jan 20 09:39:16 2011 (r217633) @@ -827,9 +827,10 @@ tmpfs_dir_getdents(struct tmpfs_node *no /* Copy the new dirent structure into the output buffer and * advance pointers. */ error = uiomove(&d, d.d_reclen, uio); - - (*cntp)++; - de = TAILQ_NEXT(de, td_entries); + if (error == 0) { + (*cntp)++; + de = TAILQ_NEXT(de, td_entries); + } } while (error == 0 && uio->uio_resid > 0 && de != NULL); /* Update the offset and cache. */ Modified: head/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vnops.c Thu Jan 20 09:37:53 2011 (r217632) +++ head/sys/fs/tmpfs/tmpfs_vnops.c Thu Jan 20 09:39:16 2011 (r217633) @@ -1349,7 +1349,7 @@ outok: MPASS(error >= -1); if (error == -1) - error = 0; + error = (cnt != 0) ? 0 : EINVAL; if (eofflag != NULL) *eofflag =
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101200939.p0K9dGXm008098>