mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* stdlib/test-canon.c: Make doesExist a directory and add more tests
for the new error case. 2004-06-02 Dmitry V. Levin <ldv@altlinux.org> Ranjani Murthy <ranmur@gmail.com> * stdlib/canonicalize.c (__realpath): Change realpath(3) to return NULL and set errno to ENOTDIR for such pathnames like "/path/to/existing-non-directory/".
This commit is contained in:
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2005-04-27 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* stdlib/test-canon.c: Make doesExist a directory and add more tests
|
||||||
|
for the new error case.
|
||||||
|
|
||||||
|
2004-06-02 Dmitry V. Levin <ldv@altlinux.org>
|
||||||
|
Ranjani Murthy <ranmur@gmail.com>
|
||||||
|
|
||||||
|
* stdlib/canonicalize.c (__realpath): Change realpath(3) to
|
||||||
|
return NULL and set errno to ENOTDIR for such pathnames like
|
||||||
|
"/path/to/existing-non-directory/".
|
||||||
|
|
||||||
2005-04-26 Ulrich Drepper <drepper@redhat.com>
|
2005-04-26 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* time/strptime_l.c (__strptime_internal): Handle 'z' to set
|
* time/strptime_l.c (__strptime_internal): Handle 'z' to set
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Return the canonical absolute name of a given file.
|
/* Return the canonical absolute name of a given file.
|
||||||
Copyright (C) 1996-2001, 2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 1996-2002, 2004, 2005 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -199,6 +199,11 @@ __realpath (const char *name, char *resolved)
|
|||||||
if (dest > rpath + 1)
|
if (dest > rpath + 1)
|
||||||
while ((--dest)[-1] != '/');
|
while ((--dest)[-1] != '/');
|
||||||
}
|
}
|
||||||
|
else if (!S_ISDIR (st.st_mode) && *end != '\0')
|
||||||
|
{
|
||||||
|
__set_errno (ENOTDIR);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dest > rpath + 1 && dest[-1] == '/')
|
if (dest > rpath + 1 && dest[-1] == '/')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Test program for returning the canonical absolute name of a given file.
|
/* Test program for returning the canonical absolute name of a given file.
|
||||||
Copyright (C) 1996, 1997, 2000, 2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 1996,1997,2000,2002,2004,2005 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by David Mosberger <davidm@azstarnet.com>.
|
Contributed by David Mosberger <davidm@azstarnet.com>.
|
||||||
|
|
||||||
@ -89,7 +89,10 @@ struct {
|
|||||||
{"SYMLINK_5", 0, "./doesNotExist", ENOENT},
|
{"SYMLINK_5", 0, "./doesNotExist", ENOENT},
|
||||||
{"SYMLINK_5/foobar", 0, "./doesNotExist", ENOENT},
|
{"SYMLINK_5/foobar", 0, "./doesNotExist", ENOENT},
|
||||||
{"doesExist/../../stdlib/doesExist", "./doesExist"},
|
{"doesExist/../../stdlib/doesExist", "./doesExist"},
|
||||||
{"doesExist/.././../stdlib/.", "."}
|
{"doesExist/.././../stdlib/.", "."},
|
||||||
|
/* 30 */
|
||||||
|
{"./doesExist/someFile/", 0, "./doesExist/someFile", ENOTDIR},
|
||||||
|
{"./doesExist/someFile/..", 0, "./doesExist/someFile", ENOTDIR},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ int
|
|||||||
do_test (int argc, char ** argv)
|
do_test (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
char * result;
|
char * result;
|
||||||
int fd, i, errors = 0;
|
int i, errors = 0;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
getcwd (cwd, sizeof(buf));
|
getcwd (cwd, sizeof(buf));
|
||||||
@ -154,7 +157,9 @@ do_test (int argc, char ** argv)
|
|||||||
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
|
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
|
||||||
symlink (symlinks[i].value, symlinks[i].name);
|
symlink (symlinks[i].value, symlinks[i].name);
|
||||||
|
|
||||||
fd = open("doesExist", O_CREAT | O_EXCL, 0777);
|
int has_dir = mkdir ("doesExist", 0777) == 0;
|
||||||
|
|
||||||
|
int fd = has_dir ? creat ("doesExist/someFile", 0777) : -1;
|
||||||
|
|
||||||
for (i = 0; i < (int) (sizeof (tests) / sizeof (tests[0])); ++i)
|
for (i = 0; i < (int) (sizeof (tests) / sizeof (tests[0])); ++i)
|
||||||
{
|
{
|
||||||
@ -208,7 +213,10 @@ do_test (int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
unlink("doesExist");
|
unlink ("doesExist/someFile");
|
||||||
|
|
||||||
|
if (has_dir)
|
||||||
|
rmdir ("doesExist");
|
||||||
|
|
||||||
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
|
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
|
||||||
unlink (symlinks[i].name);
|
unlink (symlinks[i].name);
|
||||||
|
Reference in New Issue
Block a user