Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/gen/getcwd.c,v retrieving revision 1.22 retrieving revision 1.24.6.2 diff -u -p -r1.22 -r1.24.6.2 --- src/lib/libc/gen/getcwd.c 1999/09/16 11:44:58 1.22 +++ src/lib/libc/gen/getcwd.c 2002/11/11 22:22:09 1.24.6.2 @@ -1,4 +1,4 @@ -/* $NetBSD: getcwd.c,v 1.22 1999/09/16 11:44:58 lukem Exp $ */ +/* $NetBSD: getcwd.c,v 1.24.6.2 2002/11/11 22:22:09 nathanw Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1995 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95"; #else -__RCSID("$NetBSD: getcwd.c,v 1.22 1999/09/16 11:44:58 lukem Exp $"); +__RCSID("$NetBSD: getcwd.c,v 1.24.6.2 2002/11/11 22:22:09 nathanw Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -61,8 +61,8 @@ __RCSID("$NetBSD: getcwd.c,v 1.22 1999/0 #include "extern.h" #ifdef __weak_alias -__weak_alias(getcwd,_getcwd); -__weak_alias(realpath,_realpath); +__weak_alias(getcwd,_getcwd) +__weak_alias(realpath,_realpath) #endif #define ISDOT(dp) \ @@ -92,16 +92,6 @@ realpath(path, resolved) _DIAGASSERT(path != NULL); _DIAGASSERT(resolved != NULL); -#ifdef _DIAGNOSTIC - if (path == NULL || *path == '\0') { - errno = ENOENT; - return (NULL); - } - if (resolved == NULL) { - errno = EINVAL; - return (NULL); - } -#endif /* Save the starting point. */ if ((fd = open(".", O_RDONLY)) < 0) { @@ -144,7 +134,7 @@ loop: errno = ELOOP; goto err1; } - n = readlink(p, resolved, MAXPATHLEN); + n = readlink(p, resolved, MAXPATHLEN-1); if (n < 0) goto err1; resolved[n] = '\0'; @@ -161,7 +151,7 @@ loop: * Save the last component name and get the full pathname of * the current directory. */ - (void)strncpy(wbuf, p, (sizeof(wbuf) - 1)); + (void)strlcpy(wbuf, p, sizeof(wbuf)); /* * Call the inernal internal version of getcwd which