20a2ae469089 io: support older linux ioctls 16929698e2d3 fs: implement ioctl for macOS 395bb888bd69 io: implement ioctl for macOS 8d7d15ee1a08 compiler: add support for shorthand method declarations 7d9febd13305 nl80211: add mesh peer link enum macros to constants list e851bb64df91 lib: avoid allocating print buffer before NULL check in uc_error_message_indent 5f3a7b87d962 compiler: prevent unbounded recompilation on failed module imports e2493b577250 compiler: scope named function expression names to their own body c3f0d27d812e tests: add regression test for named function expression scoping 738b55299966 vm: release owned value when property assignment fails 1ffd7c5a1011 vm: fix out-of-bounds read in single-name module import a255256db106 vm: fix SIGFPE on INT64_MIN division and modulo by -1 3f4b313d7d78 vm: do not assign to undeclared variables in strict mode e523682670a2 vm: release upvalue reference when resolving it on stack push 6a837090bea3 vm: release module scope reference in dynamic import 395a0a16b4f9 vm: guard error context capture against empty callframe stack 04f103bb2270 vm: respect exponent parity in integer exponentiation bd814a4b2ae3 vm: use UC_ARRAY instead of json_type_array in object spread 5a79aa56c15e vm: release resource type prototypes after the final GC 9c5f16c8e33a lexer: do not treat /*/ as a complete block comment a018067fd12e lexer: preserve NUL bytes in regular expression literals 65d41a1929de lexer: do not consume a sign into hexadecimal number literals 05f9bf9e5d53 lexer: fix source position of ternary question mark token 7bca646e5f88 lib: preserve embedded NUL bytes in reverse() 6fc93bf5bd95 lib: preserve embedded NUL bytes in lc() and uc() a51f4843bce5 lib: avoid passing a signed char to isxdigit() in hex() e8af70e4375c compiler: fix use-after-free of shorthand method name 467fb4406a47 compiler: declare leading variable in counting for loop initializer d256e153799b rtnl: fix stack buffer overflow parsing IFLA_LINKINFO f741ac0a144c rtnl: fix stack buffer overflow parsing RTA_MULTIPATH nexthops c41310f7c2df rtnl: fix inverted address check in multipath nexthop parsing Signed-off-by: Felix Fietkau <nbd@nbd.name>
58 lines
1.5 KiB
Diff
58 lines
1.5 KiB
Diff
From: Felix Fietkau <nbd@nbd.name>
|
|
Date: Wed, 8 Oct 2025 19:11:46 +0200
|
|
Subject: [PATCH] uloop: allow reusing the existing environment
|
|
|
|
When passing null as environment argument, reuse existing environ.
|
|
This makes it possible to avoid having to duplicate and convert it
|
|
by passing the output of getenv().
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
---
|
|
|
|
--- a/lib/uloop.c
|
|
+++ b/lib/uloop.c
|
|
@@ -1028,7 +1028,22 @@ uc_uloop_process(uc_vm_t *vm, size_t nar
|
|
|
|
if (pid == 0) {
|
|
argp = calloc(ucv_array_length(arguments) + 2, sizeof(char *));
|
|
- envp = calloc(ucv_object_length(env_arg) + 1, sizeof(char *));
|
|
+ envp = environ;
|
|
+
|
|
+ if (env_arg) {
|
|
+ envp = calloc(ucv_object_length(env_arg) + 1, sizeof(char *));
|
|
+ i = 0;
|
|
+ ucv_object_foreach(env_arg, envk, envv) {
|
|
+ buf = xprintbuf_new();
|
|
+
|
|
+ ucv_stringbuf_printf(buf, "%s=", envk);
|
|
+ ucv_to_stringbuf(vm, buf, envv, false);
|
|
+
|
|
+ envp[i++] = buf->buf;
|
|
+
|
|
+ free(buf);
|
|
+ }
|
|
+ }
|
|
|
|
if (!argp || !envp)
|
|
_exit(-1);
|
|
@@ -1038,19 +1053,6 @@ uc_uloop_process(uc_vm_t *vm, size_t nar
|
|
for (i = 0; i < ucv_array_length(arguments); i++)
|
|
argp[i+1] = ucv_to_string(vm, ucv_array_get(arguments, i));
|
|
|
|
- i = 0;
|
|
-
|
|
- ucv_object_foreach(env_arg, envk, envv) {
|
|
- buf = xprintbuf_new();
|
|
-
|
|
- ucv_stringbuf_printf(buf, "%s=", envk);
|
|
- ucv_to_stringbuf(vm, buf, envv, false);
|
|
-
|
|
- envp[i++] = buf->buf;
|
|
-
|
|
- free(buf);
|
|
- }
|
|
-
|
|
execvpe((const char *)ucv_string_get(executable),
|
|
(char * const *)argp, (char * const *)envp);
|
|
|