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.21 retrieving revision 1.22 diff -u -p -r1.21 -r1.22 --- src/lib/libc/gen/getcwd.c 1999/08/10 13:03:11 1.21 +++ src/lib/libc/gen/getcwd.c 1999/09/16 11:44:58 1.22 @@ -1,4 +1,4 @@ -/* $NetBSD: getcwd.c,v 1.21 1999/08/10 13:03:11 fvdl Exp $ */ +/* $NetBSD: getcwd.c,v 1.22 1999/09/16 11:44:58 lukem 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.21 1999/08/10 13:03:11 fvdl Exp $"); +__RCSID("$NetBSD: getcwd.c,v 1.22 1999/09/16 11:44:58 lukem Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -49,6 +49,7 @@ __RCSID("$NetBSD: getcwd.c,v 1.21 1999/0 #include #include +#include #include #include #include @@ -89,6 +90,19 @@ realpath(path, resolved) int fd, n, rootd, serrno, nlnk = 0; char *p, *q, wbuf[MAXPATHLEN]; + _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) { (void)strcpy(resolved, ".");