* src/env.c (main): When invoked with no arguments (i.e. when printing
authorJim Meyering <jim@meyering.net>
Tue, 20 Feb 2007 16:23:51 +0000 (17:23 +0100)
committerJim Meyering <jim@meyering.net>
Tue, 20 Feb 2007 16:23:51 +0000 (17:23 +0100)
the environment), use a local variable to iterate through the global
"environ" array, rather than "environ" itself.  This is solely to
avoid changing the environment for an LD_PRELOAD-substituted "puts"
or "exit" function.  Tiny patch by Harvey Eneman.  See
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9735>.
* THANKS: Update.

ChangeLog
THANKS
src/env.c

index 5de2325..9df052e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2007-02-20  Jim Meyering  <jim@meyering.net>
 
+       * src/env.c (main): When invoked with no arguments (i.e. when printing
+       the environment), use a local variable to iterate through the global
+       "environ" array, rather than "environ" itself.  This is solely to
+       avoid changing the environment for an LD_PRELOAD-substituted "puts"
+       or "exit" function.  Tiny patch by Harvey Eneman.  See
+       <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9735>.
+       * THANKS: Update.
+
        * bootstrap: Move definitions of temporary directory names and the
        new bt_regex "up" to precede all uses, so it's clearer what their
        scope is.  Also, use [.], rather than \\., since the former works
diff --git a/THANKS b/THANKS
index 25b97ed..1d7aae3 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -193,6 +193,7 @@ Hans Verkuil                        hans@wyst.hobby.nl
 Harald Dunkel                       harald.dunkel@t-online.de
 Harry Liu                           rliu@lek.ugcs.caltech.edu
 Harti Brandt                        brandt@fokus.fraunhofer.de
+Harvey Eneman                       Harvey.Eneman@oracle.com
 Helen Faulkner                      helen_ml_faulkner@yahoo.co.uk
 Herbert Xu                          herbert@gondor.apana.org.au
 Holger Berger                       hberger@ess.nec.de
index 7283926..d95ebfd 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -1,5 +1,5 @@
 /* env - run a program in a modified environment
-   Copyright (C) 1986, 1991-2005 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1991-2005, 2007 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -189,8 +189,9 @@ main (int argc, char **argv)
   /* If no program is specified, print the environment and exit. */
   if (argc <= optind)
     {
-      while (*environ)
-       puts (*environ++);
+      char *const *e = environ;
+      while (*e)
+       puts (*e++);
       exit (EXIT_SUCCESS);
     }