aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ports/unix/guts/realpath.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ports/unix/guts/realpath.c b/ports/unix/guts/realpath.c
index 085d2cb..8d8118b 100644
--- a/ports/unix/guts/realpath.c
+++ b/ports/unix/guts/realpath.c
@@ -14,7 +14,14 @@
errno = ENAMETOOLONG;
return NULL;
}
- if ((len = strlen(rname)) >= pseudo_sys_path_max()) {
+ len = strlen(rname);
+ char *ep = rname + len - 1;
+ while (ep > rname && *ep == '/') {
+ --len;
+ *(ep--) = '\0';
+ }
+
+ if (len >= pseudo_sys_path_max()) {
errno = ENAMETOOLONG;
return NULL;
}