Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen POSIX says realpath(NULL, foo) is supposed to y...
details: https://anonhg.NetBSD.org/src/rev/64b684b34bd7
branches: trunk
changeset: 750466:64b684b34bd7
user: dholland <dholland%NetBSD.org@localhost>
date: Fri Jan 01 19:59:21 2010 +0000
description:
POSIX says realpath(NULL, foo) is supposed to yield EINVAL rather than
being allowed to crash. Go figure. Closes PR lib/42559 from Stathis Kamperis.
diffstat:
lib/libc/gen/getcwd.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diffs (34 lines):
diff -r f161f28e6a2a -r 64b684b34bd7 lib/libc/gen/getcwd.c
--- a/lib/libc/gen/getcwd.c Fri Jan 01 19:51:19 2010 +0000
+++ b/lib/libc/gen/getcwd.c Fri Jan 01 19:59:21 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getcwd.c,v 1.45 2007/10/26 19:48:14 christos Exp $ */
+/* $NetBSD: getcwd.c,v 1.46 2010/01/01 19:59:21 dholland Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
#else
-__RCSID("$NetBSD: getcwd.c,v 1.45 2007/10/26 19:48:14 christos Exp $");
+__RCSID("$NetBSD: getcwd.c,v 1.46 2010/01/01 19:59:21 dholland Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -74,9 +74,14 @@
char *p, wbuf[2][MAXPATHLEN];
size_t len;
- _DIAGASSERT(path != NULL);
_DIAGASSERT(resolved != NULL);
+ /* POSIX sez we must test for this */
+ if (path == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
/*
* Build real path one by one with paying an attention to .,
* .. and symbolic link.
Home |
Main Index |
Thread Index |
Old Index