bugs in realpath

Eric Blake ebb9@byu.net
Thu Aug 25 13:13:00 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
By my reading of POSIX, realpath() has several bugs.
 realpath("//", buf) should output "//", but currently resolves to
/cygdrive/c/
 realpath("nonexistent", buf) should fail with ENOENT, but currently
resolves to `pwd`/nonexistent
 realpath(NULL, buf) should fail with EINVAL, but currently fails with EFAULT
 realpath("linktofile/x", buf) should fail with ENOTDIR, but currently
resolves to `pwd`/file/x
 realpath("c:..", buf) should resolve to "/cygdrive" (or whatever
cygdrive-prefix is, of course), but currently resolves to "/cygdrive/c"
 realpath("c:/..", buf) should resolve to "/cygdrive", but for me resolved
to a bogus "/tmp/ca"
(Plus the issue that .. is resolved incorrectly on symlinks, but fixing
that is a much bigger task and affects more than realpath)
I tested these using:
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <stdio.h>
int
main (int argc, char* argv[])
{
 char resolved[PATH_MAX];
 int i;
 if (argc == 1)
 argc = 2;
 for (i = 1; i < argc; i++)
 {
 char *res;
 errno = 0;
 res = realpath(argv[i], resolved);
 printf("'%s': %s (%s), %d %s\n", argv[i] ? argv[i] : "NULL",
 res ? res : "NULL", res == resolved ? "same" : resolved,
 errno, strerror(errno));
 }
 return 0;
}
- --
Life is short - so eat dessert first!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDDcP484KuGfSFAYARAvgVAKCK7jVk7hvyez7ieZvQ49rFxuwfkACcDoP2
7vyspKQDRJR6n4dg6E3boYA=
=7Xt4
-----END PGP SIGNATURE-----
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /