cvs commit: src/lib/libc/stdlib getenv.c

Sean Farley scf at FreeBSD.org
Fri Aug 8 00:49:42 UTC 2008


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


More information about the cvs-src mailing list