diff --git a/openbsd-compat/getcwd.c b/openbsd-compat/getcwd.c index 2d56bae19..a904291a2 100644 --- a/openbsd-compat/getcwd.c +++ b/openbsd-compat/getcwd.c @@ -70,9 +70,12 @@ getcwd(char *pt, size_t size) */ if (pt) { ptsize = 0; - if (!size) { + if (size == 0) { errno = EINVAL; return (NULL); + } else if (size == 1) { + errno = ERANGE; + return (NULL); } ept = pt + size; } else {