From owner-cvs-src@FreeBSD.ORG Sat Aug 2 02:39:30 2008 Return-Path: Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4EE61065671; Sat, 2 Aug 2008 02:39:30 +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 A33088FC12; Sat, 2 Aug 2008 02:39:30 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m722dUEd022292; Sat, 2 Aug 2008 02:39:30 GMT (envelope-from scf@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m722dU6q022291; Sat, 2 Aug 2008 02:39:30 GMT (envelope-from scf@repoman.freebsd.org) Message-Id: <200808020239.m722dU6q022291@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to scf@repoman.freebsd.org using -f From: Sean Farley Date: Sat, 2 Aug 2008 02:34:35 +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 X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2008 02:39:30 -0000 scf 2008-08-02 02:34:35 UTC FreeBSD src repository Modified files: lib/libc/stdlib getenv.c tools/regression/environ envctl.c envtest.t Log: SVN rev 181150 on 2008-08-02 02:34:35Z by scf Detect if the application has cleared the environ variable by setting the first value (environ[0]) to NULL. This is in addition to the current detection of environ being replaced, which includes being set to NULL. Without this fix, the environment is not truly wiped, but appears to be by getenv() until an *env() call is made to alter the enviroment. This change is necessary to support those applications that use this method for clearing environ such as Dovecot and Postfix. Applications such as Sendmail and the base system's env replace environ (already detected). While neither of these methods are defined by SUSv3, it is best to support them due to historic reasons and in lieu of a clean, defined method. Add extra units tests for clearing environ using four different methods: 1. Set environ to NULL pointer. 2. Set environ[0] to NULL pointer. 3. Set environ to calloc()'d NULL-terminated array. 4. Set environ to static NULL-terminated array. Noticed by: Timo Sirainen MFC after: 3 days Revision Changes Path 1.14 +12 -7 src/lib/libc/stdlib/getenv.c 1.6 +29 -12 src/tools/regression/environ/envctl.c 1.4 +41 -13 src/tools/regression/environ/envtest.t