This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
readdir.c: d_off instead of d_reclen [PATCH]
- From: Shaun Jackman <sjackman at gmail dot com>
- To: newlib at sources dot redhat dot com
- Date: Fri, 3 Jun 2005 11:38:58 -0700
- Subject: readdir.c: d_off instead of d_reclen [PATCH]
- Reply-to: Shaun Jackman <sjackman at gmail dot com>
The getdents(2) manual page indicates d_off should be used as the
offset to the next dirent.
Cheers,
Shaun
2005-06-03 Shaun Jackman <sjackman@gmail.com>
* newlib/libc/posix/readdir.c (readdir): Use d_off as the offset
to the next dirent instead of d_reclen.
* newlib/libc/posix/readdir_r.c (readdir_r): Ditto.
--- newlib/libc/posix/readdir.c- 2005-06-03 11:21:42.000000000 -0700
+++ newlib/libc/posix/readdir.c 2005-06-03 11:25:09.000000000 -0700
@@ -81,14 +81,14 @@
#endif
return NULL;
}
- if (dp->d_reclen <= 0 ||
+ if (dp->d_reclen <= 0 || dp->d_off <= 0 ||
dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return NULL;
}
- dirp->dd_loc += dp->d_reclen;
+ dirp->dd_loc += dp->d_off;
if (dp->d_ino == 0)
continue;
#ifdef HAVE_DD_LOCK
--- newlib/libc/posix/readdir_r.c- 2003-06-06 12:57:51.000000000 -0700
+++ newlib/libc/posix/readdir_r.c 2005-06-03 11:25:05.000000000 -0700
@@ -86,7 +86,7 @@
tmpdp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
memcpy (dp, tmpdp, sizeof(struct dirent));
- if (dp->d_reclen <= 0 ||
+ if (dp->d_reclen <= 0 || dp->d_off <= 0 ||
dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
@@ -94,7 +94,7 @@
*dpp = NULL;
return -1;
}
- dirp->dd_loc += dp->d_reclen;
+ dirp->dd_loc += dp->d_off;
if (dp->d_ino == 0)
continue;
#ifdef HAVE_DD_LOCK