From 0be5b3fe222c6ea7072a24e788929a5e8df134f0 Mon Sep 17 00:00:00 2001 From: reinoud Date: Tue, 16 Dec 2008 14:28:34 +0000 Subject: [PATCH] Fix endless loop occuring on empty directories listing on 512 bytes/sector media like harddiscs. Also provide provide a `safety net' on readdir so it will signal EOF when its requested an entry outside the directory. --- sys/fs/udf/udf_vnops.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index dfef7c1c1d38..8df84aaeae1a 100644 --- a/sys/fs/udf/udf_vnops.c +++ b/sys/fs/udf/udf_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vnops.c,v 1.33 2008/12/16 10:30:19 reinoud Exp $ */ +/* $NetBSD: udf_vnops.c,v 1.34 2008/12/16 14:28:34 reinoud Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -32,7 +32,7 @@ #include #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.33 2008/12/16 10:30:19 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.34 2008/12/16 14:28:34 reinoud Exp $"); #endif /* not lint */ @@ -546,8 +546,7 @@ udf_readdir(void *v) /* we are called just as long as we keep on pushing data in */ error = 0; - if ((uio->uio_offset < file_size) && - (uio->uio_resid >= sizeof(struct dirent))) { + if (uio->uio_offset < file_size) { /* allocate temporary space for fid */ lb_size = udf_rw32(udf_node->ump->logical_vol->lb_size); fid = malloc(lb_size, M_UDFTEMP, M_WAITOK); @@ -597,7 +596,7 @@ udf_readdir(void *v) } if (ap->a_eofflag) - *ap->a_eofflag = (uio->uio_offset == file_size); + *ap->a_eofflag = (uio->uio_offset >= file_size); #ifdef DEBUG if (udf_verbose & UDF_DEBUG_READDIR) {