diff options
author | Jim Meyering <jim@meyering.net> | 2007-02-20 17:23:51 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-02-20 17:23:51 +0100 |
commit | d7226387a9fb07ec3de3913f8128a31ba95deeb2 (patch) | |
tree | 5d495cae4b86d5bf0be1fb497e12b357ab456014 /src | |
parent | dd99d05b4a24966f22321793bfc45681652eceef (diff) | |
download | coreutils-d7226387a9fb07ec3de3913f8128a31ba95deeb2.tar.xz |
* 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/env.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); } |