From: Ulrich Drepper Date: Mon, 17 Mar 1997 04:11:37 +0000 (+0000) Subject: Don't copy whole `struct dirent' record, only reclen bytes. X-Git-Tag: cvs/glibc-2_0_4~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b47d1816eb38cec8ad3181a77c78bc92b0c14ec3;p=thirdparty%2Fglibc.git Don't copy whole `struct dirent' record, only reclen bytes. --- diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c index fca3eeeb5f4..fa26db6381f 100644 --- a/sysdeps/unix/readdir_r.c +++ b/sysdeps/unix/readdir_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,13 +33,12 @@ int __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) { struct dirent *dp; + size_t reclen; __libc_lock_lock (dirp->lock); do { - size_t reclen; - if (dirp->offset >= dirp->size) { /* We've emptied out our buffer. Refill it. */ @@ -60,6 +59,7 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) if (bytes <= 0) { dp = NULL; + reclen = 0; break; } dirp->size = (size_t) bytes; @@ -97,7 +97,7 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) if (dp != NULL) { - *entry = *dp; + memcpy (entry, dp, reclen); *result = entry; }