| Message ID | 1768520616-7289-10-git-send-email-mark.hatle@kernel.crashing.org |
|---|---|
| State | New |
| Headers | show |
| Series | Consolidated pseudo patches | expand |
diff --git a/ports/unix/guts/realpath.c b/ports/unix/guts/realpath.c index 8d8118b..c13eb93 100644 --- a/ports/unix/guts/realpath.c +++ b/ports/unix/guts/realpath.c @@ -14,6 +14,15 @@ errno = ENAMETOOLONG; return NULL; } + + /* We must fail if the target path doesn't exist. */ + PSEUDO_STATBUF buf; + + if (base_lstat(rname, &buf) == -1) { + errno = EINVAL; + return NULL; + } + len = strlen(rname); char *ep = rname + len - 1; while (ep > rname && *ep == '/') {