If I am correct, the environment of a process is an array of strings. The strings usually have the form "name=value", but not necessarily. I was wondering for what purposes the strings don't have the "name=value" form? Thanks.
1 Answers
I'm not aware of anything actually using or expecting environment strings that don't contain =
. Those would typically be pathological cases.
GNU env
or printenv
will faithfully print them.
For some languages, those strings will be out of reach. For instance, if you call perl
with a foo
env string, it won't show in keys(%ENV)
, though perl
would still pass it along to the commands it executes (unless you reset the whole %ENV
hash).
So one could possibly use that to bypass some environment sanitizing (though proper environment sanitizing should start with an empty environment).
Some tools (like some shells) strip them from the environment they receive and don't pass them along to commands they execute, so in general it's not a good idea to rely on that.
Beside the =
-less env strings, other pathological cases include env strings with duplicate variable name (like both foo=good
and foo=bad
passed in envp
) which has already been seen as causing vulnerabilities (like CVE-2016-2381), and env strings like =foo
(empty variable name; note that POSIX putenv()
/getenv()
can set/get that variable, but not setenv()
).

- 544,893
execve()
to execute a program, you can give whatever strings to the env argument. It is up to the program being invoked to interpret the environment strings. But I haven't seen such example. – Tim Apr 16 '18 at 13:20name=value
the shell's way of assigning values? Seeing a counterexample would clarify what you're asking about. – Jeff Schaller Apr 16 '18 at 13:26