bug-gnulib
[Top][All Lists]
Advanced

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

Re: unsafe use of dirfd in fts.c, getcwd.c, glob.c?


From: Bruno Haible
Subject: Re: unsafe use of dirfd in fts.c, getcwd.c, glob.c?
Date: Mon, 13 Sep 2010 12:39:59 +0200
User-agent: KMail/1.9.9

Hi Paul,

> Can dirfd really return -1 on real platforms, when its argument is a valid
> open directory stream?  POSIX allows that behavior, but I don't know
> of any implementations that do it.

Nothing of this sort is known for Unix platforms, but
gnulib/doc/posix-functions/dirfd.texi mentions that this problem exists on
mingw:

  Portability problems not fixed by Gnulib:
  @itemize
  @item
  This function always fails on some platforms:
  mingw.
  @end itemize

Also, see the comment in lib/fchdir.c: "FIXME - make dirfd possible on mingw".

So, for modules that attempt portability to mingw - and 'getcwd' and 'glob'
are certainly in this group - you shouldn't use dirfd for essential purposes,
but rather use file names and 'DIR *' pointers.

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]