[haiku-bugs] Re: [Haiku] #9466: Bug in readdir_r?

  • From: "hamish" <trac@xxxxxxxxxxxx>
  • Date: Wed, 20 Feb 2013 13:21:09 -0000

#9466: Bug in readdir_r?
-------------------------+-------------------------
   Reporter:  fabbo      |      Owner:  nobody
       Type:  bug        |     Status:  closed
   Priority:  normal     |  Milestone:  R1
  Component:  - General  |    Version:  R1/alpha4.1
 Resolution:  invalid    |   Keywords:
 Blocked By:             |   Blocking:
Has a Patch:  0          |   Platform:  All
-------------------------+-------------------------
Changes (by hamish):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 You are expected to allocate a dirent structure big enough for the names
 of the files in the directory. The d_name array in the struct definition
 only has space for one character. In this case, readdir_r scribbles over
 plugindir, causing the second call to readdir_r to fail and the call to
 closedir to crash.

 The reason it works on Linux is because struct dirent has a larger d_name.
 But since POSIX doesn't specify the length of the array, portable code
 shouldn't rely on that.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/9466#comment:2>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: