From owner-cvs-src@FreeBSD.ORG Fri Aug 8 00:49:42 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 247AA1065746; Fri, 8 Aug 2008 00:49:42 +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 11F678FC08; Fri, 8 Aug 2008 00:49:42 +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 m780nfTc058329; Fri, 8 Aug 2008 00:49:41 GMT (envelope-from scf@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m780nftv058328; Fri, 8 Aug 2008 00:49:41 GMT (envelope-from scf@repoman.freebsd.org) Message-Id: <200808080049.m780nftv058328@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to scf@repoman.freebsd.org using -f From: Sean Farley Date: Fri, 8 Aug 2008 00:49:28 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: RELENG_7 Cc: Subject: cvs commit: src/lib/libc/stdlib getenv.c 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: Fri, 08 Aug 2008 00:49:42 -0000 scf 2008-08-08 00:49:28 UTC FreeBSD src repository Modified files: (Branch: RELENG_7) lib/libc/stdlib getenv.c Log: SVN rev 181407 on 2008-08-08 00:49:28Z by scf MFC: r181150, r181266 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 Reviewed by: ache Revision Changes Path 1.12.2.2 +20 -13 src/lib/libc/stdlib/getenv.c