summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/readdir.c
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-02-26 21:39:32 +0000
committeralfred <alfred@FreeBSD.org>2002-02-26 21:39:32 +0000
commita375f90225175258803735ba27d7d221bb6985e3 (patch)
tree1a318fde8e8c9754078aca14434ed4e7252c1578 /lib/libc/gen/readdir.c
parent95be92ead0d9a313d94cb3ed1fa65985b7260f14 (diff)
downloadFreeBSD-src-a375f90225175258803735ba27d7d221bb6985e3.zip
FreeBSD-src-a375f90225175258803735ba27d7d221bb6985e3.tar.gz
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.
Diffstat (limited to 'lib/libc/gen/readdir.c')
-rw-r--r--lib/libc/gen/readdir.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c
index bb0d897..68d0ddd 100644
--- a/lib/libc/gen/readdir.c
+++ b/lib/libc/gen/readdir.c
@@ -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)
OpenPOWER on IntegriCloud