Hi Martin,

I spotted this report and realized that I already independently 
added some of the information that Thomas Hood is talking about
in man-pages-2.00 (Dec 2004).  I've just now amended that text 
slightly to be more accurate.

I think Thomas probably thinks that setting seolved_path to 
NULL means that realpath() will allocate a buffer that is always
large enough.  This is not the case: it only allocates up to
PATH_MAX bytes.

The current text (as it will appear in man-pages-2.04) is:

NOTES
       The  glibc  implementation  of  realpath() provides a non-
       standard extension.   If  resolved_path  is  specified  as
       NULL,  then realpath() uses malloc(3) to allocate a buffer
       of up to PATH_MAX bytes to hold the resolved pathname, and
       returns a pointer to this buffer.  The caller should deal-
       locate this buffer using free(3).

BUGS
       Avoid using this function. It is broken  by  design  since
       (unless  using the non-standard resolved_path == NULL fea-
       ture) it is impossible to determine a  suitable  size  for
       the  output  buffer,  resolved_path.  According to POSIX a
       buffer of size PATH_MAX suffices, but PATH_MAX need not be
       a  defined  constant,  and  may  have to be obtained using
       pathconf().  And asking pathconf() does not  really  help,
       since on the one hand POSIX warns that the result of path-
       conf() may be huge and unsuitable  for  mallocing  memory.
       And  on the other hand pathconf() may return -1 to signify
       that PATH_MAX is not bounded.

Please close this report.

Cheers,

Michael

-- 
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7 

Want to help with man page maintenance?  Grab the latest
tarball at ftp://ftp.win.tue.nl/pub/linux-local/manpages/
and grep the source files for 'FIXME'.

Please submit non-trivial man page suggestions as 
"diff -u" patches.

Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to