summaryrefslogtreecommitdiff
path: root/lib/libc/gen/getcwd.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-07-19 15:25:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-07-19 15:25:14 +0000
commit1e324c796e93fb154e769fef76b3a558aa0761a7 (patch)
tree737307beb556577d67a8b19cede71d13b8c0e340 /lib/libc/gen/getcwd.c
parent9e3673ea4afcf0bc718d8fdd465f049cbdd6e759 (diff)
off-by-one calculation error; getcwd() would return NULL if the buffer was
the needed length + terminating byte + 1; that 1 is not needed; assar
Diffstat (limited to 'lib/libc/gen/getcwd.c')
-rw-r--r--lib/libc/gen/getcwd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index 5234bb8ff67..c85fd5ead14 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getcwd.c,v 1.5 1998/08/14 21:39:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: getcwd.c,v 1.6 2000/07/19 15:25:13 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -190,7 +190,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;
char *npt;