diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index dc9ba6d..707c18f 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2382,7 +2382,7 @@ sys___getcwd(struct __getcwd_args *uap) return (ENODEV); buflen = uap->buflen; - if (buflen < 2) + if (buflen == 0) return (EINVAL); if (buflen > MAXPATHLEN) buflen = MAXPATHLEN; @@ -2431,14 +2431,14 @@ kern_getcwd(char *buf, size_t buflen, int *error) for (i = nch.ncp->nc_nlen - 1; i >= 0; i--) { if (bp == buf) { numcwdfail4++; - *error = ENOMEM; + *error = ERANGE; return(NULL); } *--bp = nch.ncp->nc_name[i]; } if (bp == buf) { numcwdfail4++; - *error = ENOMEM; + *error = ERANGE; return(NULL); } *--bp = '/'; @@ -2458,7 +2458,7 @@ kern_getcwd(char *buf, size_t buflen, int *error) if (!slash_prefixed) { if (bp == buf) { numcwdfail4++; - *error = ENOMEM; + *error = ERANGE; return(NULL); } *--bp = '/';