realpath(3) bug fix: There was an off-by-one error in computing the

size of the resulting canonical path.
This commit is contained in:
Jacques Vidrine 2003-08-03 23:47:39 +00:00
parent ad3dbee7a1
commit a9c8e89592
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/3/; revision=118401

View File

@ -36,6 +36,8 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)realpath.c 8.1 (Berkeley) 2/16/94";
static char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -136,7 +138,8 @@ loop:
rootd = 0;
if (*wbuf) {
if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) {
if (strlen(resolved) + strlen(wbuf) + (1-rootd) + 1 >
MAXPATHLEN) {
errno = ENAMETOOLONG;
goto err1;
}