summaryrefslogtreecommitdiffstats
path: root/sys/fs/tmpfs/tmpfs_subr.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2011-01-20 09:39:16 +0000
committerkib <kib@FreeBSD.org>2011-01-20 09:39:16 +0000
commit5c60dad7720489b9c6e0f8bab13349d156d97cd9 (patch)
tree9bdb53da252c17741e9eee12defafe37d5bb0543 /sys/fs/tmpfs/tmpfs_subr.c
parenta55d6f1de501912c63ec170b22690d2531f494bf (diff)
downloadFreeBSD-src-5c60dad7720489b9c6e0f8bab13349d156d97cd9.zip
FreeBSD-src-5c60dad7720489b9c6e0f8bab13349d156d97cd9.tar.gz
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
Diffstat (limited to 'sys/fs/tmpfs/tmpfs_subr.c')
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 84a2038..62dd0bf 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -827,9 +827,10 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio *uio, off_t *cntp)
/* 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. */
OpenPOWER on IntegriCloud