diff options
author | Andreas Schwab <schwab@suse.de> | 2023-03-29 17:00:06 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-06-13 11:28:53 +0200 |
commit | 7f750efcaa86dad4d0b748f27b82c2c066b5435b (patch) | |
tree | 7b6e384dfbba9755c572738007d835b0d3d59138 /linux-user | |
parent | fdd0df5340a8ebc8de88078387ebc85c5af7b40f (diff) |
linux-user, bsd-user: Preserve incoming order of environment variables in the target
Do not reverse the order of environment variables in the target environ
array relative to the incoming environ order. Some testsuites depend on a
specific order, even though it is not defined by any standard.
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <mvmlejfsivd.fsf@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index 5e6b2e1714..dba67ffa36 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -692,8 +692,16 @@ int main(int argc, char **argv, char **envp) envlist = envlist_create(); - /* add current environment into the list */ + /* + * add current environment into the list + * envlist_setenv adds to the front of the list; to preserve environ + * order add from back to front + */ for (wrk = environ; *wrk != NULL; wrk++) { + continue; + } + while (wrk != environ) { + wrk--; (void) envlist_setenv(envlist, *wrk); } |