summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorPedro Martelletto <pedro@cvs.openbsd.org>2005-12-16 04:52:25 +0000
committerPedro Martelletto <pedro@cvs.openbsd.org>2005-12-16 04:52:25 +0000
commit05c3b95b94d543b20d0fcb93da6c6b71884a9984 (patch)
tree9ae86634e0b1b2133c3e35fe52c531bf6a13228c /sys/ufs
parent749c35ae915a60ce9935f88ce8fba65dd1234e02 (diff)
Fix unsigned < 0 check in ufs_readdir(), okay krw@
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ufs/ufs_vnops.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index ae0455a7bc3..9ffaca12f22 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.69 2005/11/19 02:18:02 pedro Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.70 2005/12/16 04:52:24 pedro Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -1482,14 +1482,17 @@ ufs_readdir(void *v)
} */ *ap = v;
struct uio *uio = ap->a_uio;
int error;
- size_t count, lost;
+ size_t count, lost, entries;
off_t off = uio->uio_offset;
count = uio->uio_resid;
+ entries = (uio->uio_offset + count) & (DIRBLKSIZ - 1);
+
/* Make sure we don't return partial entries. */
- count -= (uio->uio_offset + count) & (DIRBLKSIZ -1);
- if (count <= 0)
+ if (count <= entries)
return (EINVAL);
+
+ count -= entries;
lost = uio->uio_resid - count;
uio->uio_resid = count;
uio->uio_iov->iov_len = count;