diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c index a7b925d2..103fbbb5 100644 --- a/src/unistd/getcwd.c +++ b/src/unistd/getcwd.c @@ -14,6 +14,12 @@ char *getcwd(char *buf, size_t size) errno = EINVAL; return 0; } - if (syscall(SYS_getcwd, buf, size) < 0) return 0; + long ret = syscall(SYS_getcwd, buf, size); + if (ret < 0) + return 0; + if (ret == 0 || buf[0] != '/') { + errno = ENOENT; + return 0; + } return buf == tmp ? strdup(buf) : buf; }