update libc argv patch
This commit is contained in:
parent
066a91bd31
commit
6a177ba62b
|
@ -10,8 +10,8 @@ index dc9af2d443..784257c48e 100644
|
|||
+++ b/repos/libports/src/lib/libc/signal.cc
|
||||
@@ -131,6 +131,9 @@ extern "C" int sigaction(int signum, const struct sigaction *act, struct sigacti
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+extern "C" int siginterrupt(int sig, int flag) { return 0; };
|
||||
+
|
||||
+
|
||||
|
@ -35,9 +35,9 @@ index 8e75e59589..2bb98b1456 100644
|
|||
setlocale.c xlocale.c setrunelocale.c \
|
||||
- ascii.c big5.c euc.co gb18030.c gb2312.c gbk.c mbsinit.c mskanji.c utf8.c \
|
||||
+ ascii.c big5.c euc.co gb18030.c gb2312.c gbk.c mskanji.c utf8.c \
|
||||
|
||||
|
||||
SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(LIBC_LOCALE_DIR)/*.c)))
|
||||
|
||||
|
||||
commit 81fc78f8e0ac66a7275e149f7f7fdc5f4f1f2979
|
||||
Author: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Wed May 27 16:35:16 2020 +0530
|
||||
|
@ -49,9 +49,9 @@ index 37c2c83f89..bc2f15a90a 100644
|
|||
--- a/repos/libports/src/lib/libc/dummies.cc
|
||||
+++ b/repos/libports/src/lib/libc/dummies.cc
|
||||
@@ -221,5 +221,15 @@ int __attribute__((weak)) madvise(void *addr, size_t length, int advice)
|
||||
|
||||
|
||||
const struct res_sym __p_type_syms[] = { };
|
||||
|
||||
|
||||
+#define DUMMY_EPERM(ret_type, ret_val, name, args) __attribute__((weak)) \
|
||||
+ret_type name args \
|
||||
+{ \
|
||||
|
@ -63,7 +63,7 @@ index 37c2c83f89..bc2f15a90a 100644
|
|||
+DUMMY_EPERM(int, -1, munlock, (const void *, size_t));
|
||||
+
|
||||
} /* extern "C" */
|
||||
|
||||
|
||||
commit f45e11626aca92be04bc9c8ed74f010ff62862dd
|
||||
Author: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Fri May 29 09:26:50 2020 +0530
|
||||
|
@ -85,7 +85,7 @@ index 150640ddf3..e511897600 100644
|
|||
DUMMY(int , -1, getpriority, (int, int))
|
||||
DUMMY(int , -1, getrusage, (int, rusage *))
|
||||
DUMMY_SILENT(uid_t , 0, getuid, (void))
|
||||
From 01bac4b0add9da8bbb4fcbe339605533ab7e7be5 Mon Sep 17 00:00:00 2001
|
||||
From 73a27bd29a3dddc9cad8fbbc6303dd09776e5bdb Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Thu, 26 Nov 2020 12:47:30 +0100
|
||||
Subject: [PATCH] libc: always set argv and envp to valid arrays
|
||||
|
@ -93,16 +93,15 @@ MIME-Version: 1.0
|
|||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The argument array passed to main(…) must be a null terminated array, even
|
||||
if argc is zero. Set at least one environment variable in any case.
|
||||
The arrays passed to main(…) must always be valid null-terminated arrays.
|
||||
|
||||
Fix #3955
|
||||
---
|
||||
repos/libports/include/libc/args.h | 29 +++++++++++++++++++++++++----
|
||||
1 file changed, 25 insertions(+), 4 deletions(-)
|
||||
repos/libports/include/libc/args.h | 19 +++++++++++++++----
|
||||
1 file changed, 15 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/repos/libports/include/libc/args.h b/repos/libports/include/libc/args.h
|
||||
index 76645d82cb..fab299b8d3 100644
|
||||
index 76645d82cb..ca9a8fd38a 100644
|
||||
--- a/repos/libports/include/libc/args.h
|
||||
+++ b/repos/libports/include/libc/args.h
|
||||
@@ -25,6 +25,7 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
||||
|
@ -113,7 +112,7 @@ index 76645d82cb..fab299b8d3 100644
|
|||
|
||||
env.config([&] (Xml_node const &node) {
|
||||
|
||||
@@ -40,12 +41,25 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
||||
@@ -40,12 +41,20 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
||||
++envc;
|
||||
});
|
||||
|
||||
|
@ -121,13 +120,8 @@ index 76645d82cb..fab299b8d3 100644
|
|||
+ if (argc == 0 && envc == 0) {
|
||||
+ /*
|
||||
+ * If argc is zero then argv is still a NULL-terminated array.
|
||||
+ *
|
||||
+ * Invent an enviromental variable in case the application
|
||||
+ * does not handle an empty environment. SHLVL=0 is
|
||||
+ * just an indication that this application lacks a parent
|
||||
+ * shell.
|
||||
+ */
|
||||
+ static char const *args[] = { nullptr, "SHLVL=0", nullptr };
|
||||
+ static char const *args[] = { nullptr, nullptr };
|
||||
+ argc = 0;
|
||||
+ argv = (char**)&args;
|
||||
+ envp = &argv[1];
|
||||
|
@ -138,22 +132,17 @@ index 76645d82cb..fab299b8d3 100644
|
|||
- argv = (char**)malloc((argc + envc + 1) * sizeof(char*));
|
||||
- envp = &argv[argc];
|
||||
+ /* arguments and environment are arranged System V style (but don't count on it) */
|
||||
+ argv = (char**)malloc((argc + max(envc, 1) + 2) * sizeof(char*));
|
||||
+ argv = (char**)malloc((argc + envc + 2) * sizeof(char*));
|
||||
+ envp = &argv[argc+1];
|
||||
|
||||
/* read the arguments */
|
||||
int arg_i = 0;
|
||||
@@ -123,6 +137,13 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
||||
@@ -123,6 +132,8 @@ static void populate_args_and_env(Libc::Env &env, int &argc, char **&argv, char
|
||||
catch (Xml_node::Nonexistent_attribute) { }
|
||||
});
|
||||
|
||||
+ /* argv and envp are both NULL terminated */
|
||||
+
|
||||
+ argv[arg_i] = NULL;
|
||||
+
|
||||
+ /* invent an env-var if none are present, see note above */
|
||||
+ if (env_i == 0)
|
||||
+ envp[env_i++] = (char*)"SHLVL=0";
|
||||
envp[env_i] = NULL;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue