summaryrefslogtreecommitdiffstats
path: root/libc/stdlib/realpath.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-20 10:09:16 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2007-11-20 10:09:16 +0000
commit244539cd0852bbcf8f21507d7ff866d8e7fcff18 (patch)
tree5a04e6a195814b645007e4ccecb128d8c7b31ee7 /libc/stdlib/realpath.c
parent1cac0350028cc4a47715f63e61379d3318b0c965 (diff)
downloaduClibc-alpine-244539cd0852bbcf8f21507d7ff866d8e7fcff18.tar.bz2
uClibc-alpine-244539cd0852bbcf8f21507d7ff866d8e7fcff18.tar.xz
Fix Makefile.in and synch them with trunk. Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/stdlib/realpath.c')
-rw-r--r--libc/stdlib/realpath.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c
index c3cc517de..aae8580a5 100644
--- a/libc/stdlib/realpath.c
+++ b/libc/stdlib/realpath.c
@@ -58,6 +58,14 @@ char resolved_path[];
int readlinks = 0;
int n;
+ if (path == NULL) {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+ if (*path == '\0') {
+ __set_errno(ENOENT);
+ return NULL;
+ }
/* Make a copy of the source path since we may need to modify it. */
if (strlen(path) >= PATH_MAX - 2) {
__set_errno(ENAMETOOLONG);
@@ -66,15 +74,10 @@ char resolved_path[];
strcpy(copy_path, path);
path = copy_path;
max_path = copy_path + PATH_MAX - 2;
- /* If it's a relative pathname use getwd for starters. */
+ /* If it's a relative pathname use getcwd for starters. */
if (*path != '/') {
/* Ohoo... */
-#define HAVE_GETCWD
-#ifdef HAVE_GETCWD
getcwd(new_path, PATH_MAX - 1);
-#else
- getwd(new_path);
-#endif
new_path += strlen(new_path);
if (new_path[-1] != '/')
*new_path++ = '/';