Full Disclosure mailing list archives
Re: Re: readdir_r considered harmful
From: Ulrich Drepper <drepper () gmail com>
Date: Sat, 5 Nov 2005 17:53:42 -0800
On 11/5/05, Casper.Dik () sun com <Casper.Dik () sun com> wrote:
Why not: 4. Require the readdir() implementation to use state local to dirp. I've never understood the rationale behind readdir_r;
Then you never really understood the implementation, seems. Of course all implementations keep the content of the directory as read with getdents or so in the DIR descriptor. But it is usually not the case that the whole content fits into the buffer allocated. One could, of course, resize the buffer to fit the content of the directory read, even if this means reserving hundreds or thousands of kBs. But this is not how most implementations work. Instead implementations keep work similar to every buffered file I/O operation. But this means that buffer content is replaced. If this happens and some thread uses readdir() instead of readdir_r(), the returned string pointer suddenly becomes invalid since it points to memory which has been replaced. Next time, before you make such comments, ask Don Cragun to explain things to you.
_______________________________________________ Full-Disclosure - We believe in it. Charter: http://lists.grok.org.uk/full-disclosure-charter.html Hosted and sponsored by Secunia - http://secunia.com/
Current thread:
- readdir_r considered harmful Ben Hutchings (Nov 01)
- Re: readdir_r considered harmful 3APA3A (Nov 01)
- Re: readdir_r considered harmful Ben Hutchings (Nov 01)
- Re: readdir_r considered harmful Ben Hutchings (Nov 01)
- Re: readdir_r considered harmful Casper . Dik (Nov 05)
- Re: Re: readdir_r considered harmful Ulrich Drepper (Nov 05)
- Re: Re: readdir_r considered harmful Casper . Dik (Nov 06)
- Re: Re: readdir_r considered harmful Ulrich Drepper (Nov 06)
- Re: Re: readdir_r considered harmful Casper . Dik (Nov 07)
- Re: Re: readdir_r considered harmful Andrew Miller (Nov 07)
- Re: Re: readdir_r considered harmful Ulrich Drepper (Nov 05)
- Re: Re: readdir_r considered harmful Andrew Farmer (Nov 07)
- Re: Re: readdir_r considered harmful Casper . Dik (Nov 08)
- Re: readdir_r considered harmful 3APA3A (Nov 01)