about summary refs log tree commit diff
path: root/stdlib/canonicalize.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-04-27 07:37:00 +0000
committerUlrich Drepper <drepper@redhat.com>2005-04-27 07:37:00 +0000
commit0f888d8ec6e038895be5d0a562d90be5e930a88a (patch)
tree0b98ab87be4952d2ba858e1710ea894826f4e4cb /stdlib/canonicalize.c
parent935f3e6715f2f178159eef1501ae30ad53a68150 (diff)
downloadglibc-0f888d8ec6e038895be5d0a562d90be5e930a88a.tar.gz
glibc-0f888d8ec6e038895be5d0a562d90be5e930a88a.tar.xz
glibc-0f888d8ec6e038895be5d0a562d90be5e930a88a.zip
* 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/".
Diffstat (limited to 'stdlib/canonicalize.c')
-rw-r--r--stdlib/canonicalize.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 2168bbd90e..9fc24b7d92 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -1,5 +1,5 @@
 /* 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.
 
    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)
 		  while ((--dest)[-1] != '/');
 	    }
+	  else if (!S_ISDIR (st.st_mode) && *end != '\0')
+	    {
+	      __set_errno (ENOTDIR);
+	      goto error;
+	    }
 	}
     }
   if (dest > rpath + 1 && dest[-1] == '/')