1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Handle unnecessary padding in getdents64.

The getdents64 syscall adds on 32-but platforms padding which isn't needed
and not included in the userlevel data structure definition.  We have to
avoid copying those padding bytes in the readdir64_r function.
This commit is contained in:
Ulrich Drepper
2010-04-03 23:51:40 -07:00
parent 3fedf0feb7
commit 1a81139728
3 changed files with 20 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02
/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02,10
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@ -113,7 +113,17 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result)
while (dp->d_ino == 0);
if (dp != NULL)
*result = memcpy (entry, dp, reclen);
{
#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));
#endif
*result = memcpy (entry, dp, reclen);
#ifdef GETDENTS_64BIT_ALIGNED
entry->d_reclen = reclen;
#endif
}
else
*result = NULL;