From owner-cvs-all@FreeBSD.ORG Fri Jul 20 23:30:14 2007 Return-Path: Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 048B816A419; Fri, 20 Jul 2007 23:30:14 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E886413C457; Fri, 20 Jul 2007 23:30:13 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6KNUDsw047598; Fri, 20 Jul 2007 23:30:13 GMT (envelope-from scf@repoman.freebsd.org) Received: (from scf@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6KNUDT4047597; Fri, 20 Jul 2007 23:30:13 GMT (envelope-from scf) Message-Id: <200707202330.l6KNUDT4047597@repoman.freebsd.org> From: Sean Farley Date: Fri, 20 Jul 2007 23:30:13 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/lib/libc/stdlib getenv.c src/tools/regression/environ envctl.c envtest.t timings.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2007 23:30:14 -0000 scf 2007-07-20 23:30:13 UTC FreeBSD src repository Modified files: lib/libc/stdlib getenv.c tools/regression/environ envctl.c envtest.t timings.c Log: Added environ-replacement detection. For programs that "clean" (i.e., su) or replace (i.e., zdump) the environment after a call to setenv(), putenv() or unsetenv() has been made, a few changes were made. - getenv() will return the value from the new environ array. - setenv() was split into two functions: __setenv() which is most of the previous setenv() without checks on the name and setenv() which contains the checks before calling __setenv(). - setenv(), putenv() and unsetenv() will unset all previous values and call __setenv() on all entries in the new environ array which in turn adds them to the end of the envVars array. Calling __setenv() instead of setenv() is done to avoid the temporary replacement of the '=' in a string with a NUL byte. Some strings may be read-only data. Added more regression checks for clearing the environment array. Replaced gettimeofday() with getrusage() in timing regression check for better accuracy. Fixed an off-by-one bug in __remove_putenv() in the use of memmove(). This went unnoticed due to the allocation of double the number of environ entries when building envVars. Fixed a few spelling mistakes in the comments. Reviewed by: ache Approved by: wes Approved by: re (kensmith) Revision Changes Path 1.10 +163 -78 src/lib/libc/stdlib/getenv.c 1.2 +18 -8 src/tools/regression/environ/envctl.c 1.2 +21 -0 src/tools/regression/environ/envtest.t 1.2 +31 -26 src/tools/regression/environ/timings.c