Date: Wed, 24 Oct 2001 05:40:02 -0700 (PDT) From: "Carlos F. A. Paniago" <pan@cnpm.embrapa.br> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/30631: readdir_r() SEGV on large directories Message-ID: <200110241240.f9OCe2T97018@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/30631; it has been noted by GNATS. From: "Carlos F. A. Paniago" <pan@cnpm.embrapa.br> To: freebsd-gnats-submit@FreeBSD.org, jfbauer@nfr.com Cc: Subject: Re: misc/30631: readdir_r() SEGV on large directories Date: Wed, 24 Oct 2001 10:38:20 -0200 I traced the problem . The problem occurs only with -pthread library (not the normal libc). The problem is to memcpy the structure memcpy(entry, dp, sizeof *entry); in the pthread library sometimes dp doen't have the correct size (I don't know why or where this is happening). I know that if we change this to memcpy(entry, dp, _GENERIC_DIRSIZ(dp)); it begins to work (and we cut a lot of unnecessary copy in this ugly struct that is dirent). The patch to solve this is here (someone have to test and apply): in the /usr/src directory: ------------ diff -c lib/libc/gen/readdir.c.old lib/libc/gen/readdir.c *** lib/libc/gen/readdir.c.old Wed Oct 24 10:21:17 2001 --- lib/libc/gen/readdir.c Wed Oct 24 10:23:35 2001 *************** *** 111,117 **** errno = saved_errno; if (dp != NULL) ! memcpy(entry, dp, sizeof *entry); #ifdef _THREAD_SAFE _FD_UNLOCK(dirp->dd_fd, FD_READ); --- 111,117 ---- errno = saved_errno; if (dp != NULL) ! memcpy(entry, dp, _GENERIC_DIRSIZ(dp)); #ifdef _THREAD_SAFE _FD_UNLOCK(dirp->dd_fd, FD_READ); ------------- Thanks for fixing this: Paniago To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200110241240.f9OCe2T97018>