diff options
author | Ulrich Drepper <drepper@gmail.com> | 2010-12-19 16:00:59 -0500 |
---|---|---|
committer | Petr Baudis <pasky@suse.cz> | 2011-02-03 16:55:57 +0100 |
commit | 17a0fde05783e137a8dc9cc4d913a8900862feae (patch) | |
tree | 5d2aab912bb14bdbc37631b6d42a1cc7d804f92a /sysdeps | |
parent | 9a1af187c1be4c7893a5ea8371520899f49a6a9d (diff) | |
download | glibc-17a0fde05783e137a8dc9cc4d913a8900862feae.tar.gz glibc-17a0fde05783e137a8dc9cc4d913a8900862feae.tar.xz glibc-17a0fde05783e137a8dc9cc4d913a8900862feae.zip |
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. (cherry picked from commit db753e2cfb2051ebf20dc089f87c5b1297cc2cff)
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/unix/readdir_r.c | 3 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c index 93727912c1..e166174883 100644 --- a/sysdeps/unix/readdir_r.c +++ b/sysdeps/unix/readdir_r.c @@ -117,7 +117,8 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result) #ifdef GETDENTS_64BIT_ALIGNED /* The d_reclen value might include padding which is not part of the DIRENT_TYPE data structure. */ - reclen = MIN (reclen, sizeof (DIRENT_TYPE)); + reclen = MIN (reclen, + offsetof (DIRENT_TYPE, d_name) + sizeof (dp->d_name)); #endif *result = memcpy (entry, dp, reclen); #ifdef GETDENTS_64BIT_ALIGNED diff --git a/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c b/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c index adb92db6af..12ca1a1ef7 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c +++ b/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c @@ -1,4 +1,5 @@ #define readdir64_r __no_readdir64_r_decl +#define GETDENTS_64BIT_ALIGNED 1 #include <sysdeps/unix/readdir_r.c> #undef readdir64_r weak_alias (__readdir_r, readdir64_r) |