summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getcwd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index 4797f7c..2757d3b 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -78,6 +78,10 @@ getcwd(pt, size)
errno = EINVAL;
return (NULL);
}
+ if (size == 1) {
+ errno = ERANGE;
+ return (NULL);
+ }
ept = pt + size;
} else {
if ((pt = malloc(ptsize = 1024 - 4)) == NULL)
@@ -187,7 +191,7 @@ getcwd(pt, size)
* Check for length of the current name, preceding slash,
* leading slash.
*/
- if (bpt - pt <= dp->d_namlen + (first ? 1 : 2)) {
+ if (bpt - pt < dp->d_namlen + (first ? 1 : 2)) {
size_t len, off;
if (!ptsize) {
OpenPOWER on IntegriCloud