Actions
Bug #13579
closedreaddir(3C) and closedir(3C) should document dirent lifetime
Start date:
Due date:
% Done:
100%
Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:
Description
The readdir(3C)
routine returns pointers to a private buffer attached to the struct DIR
returned by opendir(3C)
and at times overwritten (and thus invalidated) by subsequent readdir()
calls. The manual notes that:
The pointer returned by readdir() points to data that can be overwritten by another call to readdir() on the same directory stream. These data are not overwritten by another call to readdir() on a different directory stream.
The text in both the readdir(3C)
and the closedir(3C)
pages should explicitly call out the fact that a closedir(3C)
will also invalidate any pointers previously returned by readdir()
, as it frees the dd_buf
while tearing down the struct DIR
.
Updated by Joshua M. Clulow about 1 year ago
See also, the libc-coord
mailing list: https://www.openwall.com/lists/libc-coord/2021/02/23/1
Updated by Robert Mustacchi about 1 year ago
I tested this mainly by confirming with man(1) that the pages still rendered in a reasonable way.
Updated by Electric Monk about 1 year ago
- Status changed from New to Closed
- % Done changed from 0 to 100
git commit 3aa10614c270c8e3c84f2fe819f8fc4db741f47e
commit 3aa10614c270c8e3c84f2fe819f8fc4db741f47e Author: Robert Mustacchi <rm@fingolfin.org> Date: 2021-03-04T22:03:48.000Z 13579 readdir(3C) and closedir(3C) should document dirent lifetime Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
Actions