Bug#239427: realpath() incorrectly described in /usr/include/stdlib.h
Package: libc6-dev
Version: 2.3.2.ds1-11
Severity: minor
The description of realpath() in /usr/include/stdlib.h begins this way:
/* Return the canonical absolute name of file NAME.
It then continues:
The last file name component need not exist, and may be a symlink
to a nonexistent file.
This is not true. The function returns the null string if the last
file name component fails to exist. Here's proof.
jdthood@thanatos:/tmp$ cat s.c
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
main(int argc, char ** argv)
{
char f[] = "/tmp/foo";
char buf[PATH_MAX];
printf("%s %s\n", f, realpath(f,buf));
}
jdthood@thanatos:/tmp$ gcc s.c
jdthood@thanatos:/tmp$ ls -l foo bar
ls: bar: No such file or directory
lrwxrwxrwx 1 jdthood jdthood 3 2004-03-22 18:09 foo -> bar
jdthood@thanatos:/tmp$ ./a.out
/tmp/foo (null)
jdthood@thanatos:/tmp$ touch bar
jdthood@thanatos:/tmp$ ls -l foo bar
-rw-r--r-- 1 jdthood jdthood 0 2004-03-22 18:10 bar
lrwxrwxrwx 1 jdthood jdthood 3 2004-03-22 18:09 foo -> bar
jdthood@thanatos:/tmp$ ./a.out
/tmp/foo /tmp/bar
The false sentence quoted above should be removed from stdlib.h.
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (800, 'testing'), (700, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.4.24
Locale: LANG=en_IE@euro, LC_CTYPE=en_IE@euro
Versions of packages libc6-dev depends on:
ii libc6 2.3.2.ds1-11 GNU C Library: Shared libraries an
ii linux-kernel-headers 2.5.999-test7-bk-15 Linux Kernel Headers for developme
-- no debconf information
Reply to: