Module Name:    src
Committed By:   riz
Date:           Mon Nov 22 00:20:27 UTC 2010

Modified Files:
        src/lib/libc/stdlib [netbsd-5]: getenv.c

Log Message:
Pull up following revision(s) (requested by tron in ticket #1474):
        lib/libc/stdlib/getenv.c: revision 1.33 via patch
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
  results e.g. for " getenv("A=3DB") " if an environment variable "A"
  with value "B=3DC" exists.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.26.1 src/lib/libc/stdlib/getenv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/getenv.c
diff -u src/lib/libc/stdlib/getenv.c:1.18 src/lib/libc/stdlib/getenv.c:1.18.26.1
--- src/lib/libc/stdlib/getenv.c:1.18	Sun Sep 25 20:08:01 2005
+++ src/lib/libc/stdlib/getenv.c	Mon Nov 22 00:20:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: getenv.c,v 1.18 2005/09/25 20:08:01 christos Exp $	*/
+/*	$NetBSD: getenv.c,v 1.18.26.1 2010/11/22 00:20:27 riz Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)getenv.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: getenv.c,v 1.18 2005/09/25 20:08:01 christos Exp $");
+__RCSID("$NetBSD: getenv.c,v 1.18.26.1 2010/11/22 00:20:27 riz Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -67,6 +67,8 @@
 	char *result;
 
 	_DIAGASSERT(name != NULL);
+	if (strchr(name, '=') != NULL)
+		return NULL;
 
 	rwlock_rdlock(&__environ_lock);
 	result = __findenv(name, &offset);
@@ -83,6 +85,11 @@
 
 	_DIAGASSERT(name != NULL);
 
+	if (strchr(name, '=') != NULL) {
+		errno = ENOENT;
+		return -1;
+	}
+
 	rwlock_rdlock(&__environ_lock);
 	result = __findenv(name, &offset);
 	if (result == NULL) {

Reply via email to