More accurate computatin of reclen in readdir_r.

Alignment issue can increase the reclen limit.
Make sure Linux 64-bit readdir_r also accounts for 64-bit alignment
in getdents.
This commit is contained in:
Ulrich Drepper 2010-12-19 16:00:59 -05:00
parent 283007197c
commit db753e2cfb
3 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2010-12-19 Ulrich Drepper <drepper@gmail.com>
* sysdeps/unix/readdir_r.c (__READDIR_R): Compute reclen more accurate.
* sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c: Define
GETDENTS_64BIT_ALIGNED.
2010-12-14 Ulrich Drepper <dreper@gmail.com> 2010-12-14 Ulrich Drepper <dreper@gmail.com>
* sysdeps/i386/i686/multiarch/strcmp.S: Undo accident checkin. * sysdeps/i386/i686/multiarch/strcmp.S: Undo accident checkin.

View File

@ -117,7 +117,8 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result)
#ifdef GETDENTS_64BIT_ALIGNED #ifdef GETDENTS_64BIT_ALIGNED
/* The d_reclen value might include padding which is not part of /* The d_reclen value might include padding which is not part of
the DIRENT_TYPE data structure. */ the DIRENT_TYPE data structure. */
reclen = MIN (reclen, sizeof (DIRENT_TYPE)); reclen = MIN (reclen,
offsetof (DIRENT_TYPE, d_name) + sizeof (dp->d_name));
#endif #endif
*result = memcpy (entry, dp, reclen); *result = memcpy (entry, dp, reclen);
#ifdef GETDENTS_64BIT_ALIGNED #ifdef GETDENTS_64BIT_ALIGNED

View File

@ -1,4 +1,5 @@
#define readdir64_r __no_readdir64_r_decl #define readdir64_r __no_readdir64_r_decl
#define GETDENTS_64BIT_ALIGNED 1
#include <sysdeps/unix/readdir_r.c> #include <sysdeps/unix/readdir_r.c>
#undef readdir64_r #undef readdir64_r
weak_alias (__readdir_r, readdir64_r) weak_alias (__readdir_r, readdir64_r)