Re: [Full-disclosure] Re: readdir_r considered harmful

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/5/05, Casper.Dik@xxxxxxx <Casper.Dik@xxxxxxx> 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 courseall implementations keep the content of the directory as read withgetdents or so in the DIR descriptor.  But it is usually not the casethat the whole content fits into the buffer allocated.  One could, ofcourse, resize the buffer to fit the content of the directory read,even if this means reserving hundreds or thousands of kBs.  But thisis not how most implementations work.
Instead implementations keep work similar to every buffered file I/Ooperation.  But this means that buffer content is replaced.  If thishappens and some thread uses readdir() instead of readdir_r(), thereturned string pointer suddenly becomes invalid since it points tomemory which has been replaced.
Next time, before you make such comments, ask Don Cragun to explainthings to you.

[Index of Archives]     [Linux Security]     [Netfilter]     [PHP]     [Yosemite News]     [Linux Kernel]

  Powered by Linux