diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/unistd/getcwd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c index 2e540cd4..a7b925d2 100644 --- a/src/unistd/getcwd.c +++ b/src/unistd/getcwd.c @@ -7,7 +7,13 @@ char *getcwd(char *buf, size_t size) { char tmp[PATH_MAX]; - if (!buf) buf = tmp, size = PATH_MAX; + if (!buf) { + buf = tmp; + size = PATH_MAX; + } else if (!size) { + errno = EINVAL; + return 0; + } if (syscall(SYS_getcwd, buf, size) < 0) return 0; return buf == tmp ? strdup(buf) : buf; } |