[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] {print,}env -0
From: |
Eric Blake |
Subject: |
Re: [RFC] {print,}env -0 |
Date: |
Wed, 28 Oct 2009 06:24:33 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Jim Meyering on 10/28/2009 5:56 AM:
> And to add to the fun, on Solaris 10 I see this baloney:
>
> $ /bin/env a=b=c /usr/ucb/printenv a=b
> b=c
Wow. So now that tcsh isn't the only other implementation, and since the
behavior is different between the two buggy implementations, we're
justified in this patch. OK to commit?
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkroOAEACgkQ84KuGfSFAYBcKACg1Xe1TgNA8/xivTfcpNxl6RIs
gYMAnjzi7+qV2SxEeoI4xvAMB05//zN3
=Fu2+
-----END PGP SIGNATURE-----
>From d0c5ae636c07babdf2041f204c71c212ecd99684 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 28 Oct 2009 06:21:24 -0600
Subject: [PATCH] printenv: ignore bogus variable names
Exposed by env a=b=c printenv a=b.
* src/printenv.c (main): Silently reject = in names.
* tests/misc/printenv: Test for it.
* NEWS: Document this.
---
NEWS | 3 ++-
src/printenv.c | 4 ++++
tests/misc/printenv | 6 ++++++
3 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/NEWS b/NEWS
index 442ce13..35d1413 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,8 @@ GNU coreutils NEWS -*-
outline -*-
[bug introduced in coreutils-8.0]
env -u A=B now fails, rather than silently adding A to the
- environment. [the bug dates back to the initial implementation]
+ environment. Likewise, printenv A=B silently ignores the invalid
+ name. [the bugs date back to the initial implementation]
md5sum now prints checksums atomically so that concurrent
processes will not intersperse their output.
diff --git a/src/printenv.c b/src/printenv.c
index 6bc03f4..4c83972 100644
--- a/src/printenv.c
+++ b/src/printenv.c
@@ -126,6 +126,10 @@ main (int argc, char **argv)
{
bool matched = false;
+ /* 'printenv a=b' is silent, even if 'a=b=c' is in environ. */
+ if (strchr (argv[i], '='))
+ continue;
+
for (env = environ; *env; ++env)
{
ep = *env;
diff --git a/tests/misc/printenv b/tests/misc/printenv
index bbda1db..bc51fca 100755
--- a/tests/misc/printenv
+++ b/tests/misc/printenv
@@ -77,4 +77,10 @@ echo b > exp || framework_failure
env -- -a=b printenv -- -a > out || fail=1
compare exp out || fail=1
+# Silently reject invalid env-var names.
+# Bug present through coreutils 8.0.
+env a=b=c printenv a=b > out
+test $? = 1 || fail=1
+test -s out && fail=1
+
Exit $fail
--
1.6.5.rc1
- Re: [RFC] {print,}env -0, (continued)
- Re: [RFC] {print,}env -0, Pádraig Brady, 2009/10/26
- Re: [RFC] {print,}env -0, Jim Meyering, 2009/10/26
- Re: [RFC] {print,}env -0, Bauke Jan Douma, 2009/10/26
- Re: [RFC] {print,}env -0, Jim Meyering, 2009/10/27
- Re: [RFC] {print,}env -0, Eric Blake, 2009/10/27
- Re: [RFC] {print,}env -0, Pádraig Brady, 2009/10/27
- Re: [RFC] {print,}env -0, Jim Meyering, 2009/10/27
- Re: [RFC] {print,}env -0, Eric Blake, 2009/10/27
- Re: [RFC] {print,}env -0, Pádraig Brady, 2009/10/28
- Re: [RFC] {print,}env -0, Jim Meyering, 2009/10/28
- Re: [RFC] {print,}env -0,
Eric Blake <=
- Re: [RFC] {print,}env -0, Jim Meyering, 2009/10/28