2008-04-19 Dmitry V. Levin <ldv@altlinux.org>
* file.c [_LFS64_LARGEFILE] (sys_getdents64): Do the same
d_reclen check as in sys_getdents: warn if d_reclen is 0 rather
than looping forever.
[FREEBSD] (sys_getdirentries): Likewise.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/file.c b/file.c
index 25fb531..c038a55 100644
--- a/file.c
+++ b/file.c
@@ -2350,8 +2350,7 @@
#endif
int
-sys_getdents(tcp)
-struct tcb *tcp;
+sys_getdents(struct tcb *tcp)
{
int i, len, dents = 0;
char *buf;
@@ -2434,8 +2433,7 @@
#if _LFS64_LARGEFILE
int
-sys_getdents64(tcp)
-struct tcb *tcp;
+sys_getdents64(struct tcb *tcp)
{
int i, len, dents = 0;
char *buf;
@@ -2487,6 +2485,10 @@
d->d_namlen, d->d_namlen, d->d_name);
}
#endif /* SUNOS4 */
+ if (!d->d_reclen) {
+ tprintf("/* d_reclen == 0, problem here */");
+ break;
+ }
i += d->d_reclen;
dents++;
}
@@ -2502,8 +2504,7 @@
#ifdef FREEBSD
int
-sys_getdirentries(tcp)
-struct tcb * tcp;
+sys_getdirentries(struct tcb *tcp)
{
int i, len, dents = 0;
long basep;
@@ -2539,6 +2540,10 @@
tprintf(", d_namlen=%u, d_name=\"%.*s\"}",
d->d_namlen, d->d_namlen, d->d_name);
}
+ if (!d->d_reclen) {
+ tprintf("/* d_reclen == 0, problem here */");
+ break;
+ }
i += d->d_reclen;
dents++;
}