From 601dab0210e46b8eba4dbe452ba24b22ddfaf45e Mon Sep 17 00:00:00 2001 From: dd Date: Thu, 28 Jun 2001 21:50:53 +0000 Subject: Fix a one-byte overrun. PR: 28472 Submitted by: David Xu Obtained from: OpenBSD --- lib/libc/gen/basename.c | 2 +- lib/libc/gen/dirname.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c index b68ef3f..09998cf 100644 --- a/lib/libc/gen/basename.c +++ b/lib/libc/gen/basename.c @@ -66,7 +66,7 @@ basename(path) while (startp > path && *(startp - 1) != '/') startp--; - if (endp - startp + 1 > sizeof(bname)) { + if (endp - startp + 2 > sizeof(bname)) { errno = ENAMETOOLONG; return(NULL); } diff --git a/lib/libc/gen/dirname.c b/lib/libc/gen/dirname.c index 5f6019e..8bc9186 100644 --- a/lib/libc/gen/dirname.c +++ b/lib/libc/gen/dirname.c @@ -69,7 +69,7 @@ dirname(path) } while (endp > path && *endp == '/'); } - if (endp - path + 1 > sizeof(bname)) { + if (endp - path + 2 > sizeof(bname)) { errno = ENAMETOOLONG; return(NULL); } -- cgit v1.1