aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/unix/sys.c
diff options
context:
space:
mode:
authorSteve Vinoski <[email protected]>2010-04-21 14:00:55 -0400
committerBjörn Gustavsson <[email protected]>2010-05-03 13:36:47 +0200
commit6f40c6686d5e94aa2cead2739f61a45c594a7d6a (patch)
tree7b952eca244d3cf0e43b55c55a2e875464ec9943 /erts/emulator/sys/unix/sys.c
parent3a68c36ca7aed71d643ea29460e36fec7e56817d (diff)
downloadotp-6f40c6686d5e94aa2cead2739f61a45c594a7d6a.tar.gz
otp-6f40c6686d5e94aa2cead2739f61a45c594a7d6a.tar.bz2
otp-6f40c6686d5e94aa2cead2739f61a45c594a7d6a.zip
allow open_port to set env vars containing a trailing '=' character
The erlang:open_port spawn and spawn_executable directives can include an {env, Env} directive to set up environment variables for the spawned process. A bug in ert/emulator/sys/unix/sys.c prevented applications from using {env, Env} to set an environment variable whose value ended with a '=' (equal sign) character; the code mistook the trailing equal sign as an indication that an environment variable was to be cleared from the environment of the spawned process. For example, passing an {env, Env} of {env, [{"foo", "bar="}]} would result in the code in sys.c seeing a string of the form "foo=bar=" The code would see the final '=' character and assume the directive wanted to clear a variable named "foo=bar" from the environment of the spawned process, rather than seeing it as a directive to set the environment variable "foo" to the value "bar=". Fix this problem and add a new regression test for it to the port test suite.
Diffstat (limited to 'erts/emulator/sys/unix/sys.c')
-rw-r--r--erts/emulator/sys/unix/sys.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 267f7d07aa..50b208848f 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -1325,7 +1325,8 @@ static char **build_unix_environment(char *block)
}
for (j = 0; j < i; j++) {
- if (cpp[j][strlen(cpp[j])-1] == '=') {
+ size_t last = strlen(cpp[j])-1;
+ if (cpp[j][last] == '=' && strchr(cpp[j], '=') == cpp[j]+last) {
cpp[j] = cpp[--len];
}
}