[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3] linux-user, bsd-user: preserve incoming order of environment
From: |
Andreas Schwab |
Subject: |
[PATCH v3] linux-user, bsd-user: preserve incoming order of environment variables in the target |
Date: |
Wed, 29 Mar 2023 17:00:06 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
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>
---
bsd-user/main.c | 10 +++++++++-
linux-user/main.c | 10 +++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 89f225dead..eff834e8d8 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -298,8 +298,16 @@ int main(int argc, char **argv)
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);
}
diff --git a/linux-user/main.c b/linux-user/main.c
index 4b18461969..f0173ceefa 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -690,8 +690,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);
}
--
2.40.0
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
- [PATCH v3] linux-user, bsd-user: preserve incoming order of environment variables in the target,
Andreas Schwab <=