Project

General

Profile

Actions

Bug #13579

closed

readdir(3C) and closedir(3C) should document dirent lifetime

Added by Joshua M. Clulow 7 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Category:
manpage - manual pages
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.

Actions #1

Updated by Joshua M. Clulow 7 months ago

See also, the libc-coord mailing list: https://www.openwall.com/lists/libc-coord/2021/02/23/1

Actions #2

Updated by Robert Mustacchi 7 months ago

  • Assignee set to Robert Mustacchi
Actions #3

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 1294
Actions #4

Updated by Robert Mustacchi 7 months ago

I tested this mainly by confirming with man(1) that the pages still rendered in a reasonable way.

Actions #5

Updated by Electric Monk 7 months 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

Also available in: Atom PDF