use _GENERIC_DIRSIZ(dp) to avoid copying too much of the dirent over

the user supplied buffer.  this can be a problem when the user doesn't
supply a full dirent and we corrupt their memory.
This commit is contained in:
Alfred Perlstein 2002-02-26 21:39:32 +00:00
parent 08b38b1ff7
commit ef18a7a841

View File

@ -113,11 +113,11 @@ readdir_r(dirp, entry, result)
if (__isthreaded) {
_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
if ((dp = _readdir_unlocked(dirp)) != NULL)
memcpy(entry, dp, sizeof *entry);
memcpy(entry, dp, _GENERIC_DIRSIZ(dp));
_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
}
else if ((dp = _readdir_unlocked(dirp)) != NULL)
memcpy(entry, dp, sizeof *entry);
memcpy(entry, dp, _GENERIC_DIRSIZ(dp));
if (errno != 0) {
if (dp == NULL)