summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2022-05-05 20:00:05 +0200
committerBenBE <BenBE@geshi.org>2022-05-06 14:35:50 +0200
commit4f1269cc9f681f7e31361f8293a6bca5a3ec1e82 (patch)
treef00d88a18d08ef74e1cf88e6daa86224a4c43bbd
parent0388b30077b55fb02ac4b49ee3acc9b4d4aad577 (diff)
Ensure buffer for environment is large enough on NetBSD
-rw-r--r--netbsd/Platform.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/netbsd/Platform.c b/netbsd/Platform.c
index 1812ddd4..cf6079db 100644
--- a/netbsd/Platform.c
+++ b/netbsd/Platform.c
@@ -311,7 +311,13 @@ char* Platform_getProcessEnv(pid_t pid) {
for (char** p = ptr; *p; p++) {
size_t len = strlen(*p) + 1;
- if (size + len > capacity) {
+ while (size + len > capacity) {
+ if (capacity > (SIZE_MAX / 2)) {
+ free(env);
+ env = NULL;
+ goto end;
+ }
+
capacity *= 2;
env = xRealloc(env, capacity);
}
@@ -327,6 +333,7 @@ char* Platform_getProcessEnv(pid_t pid) {
env[size + 1] = 0;
}
+end:
(void) kvm_close(kt);
return env;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy