diff options
author | Benny Baumann <BenBE@geshi.org> | 2022-05-05 20:01:30 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2022-05-06 14:35:50 +0200 |
commit | db9326896845ad268436d22c0422e769af0b1a3c (patch) | |
tree | b69105638755e9f5a79282c8067fab5f1c406094 | |
parent | 4f1269cc9f681f7e31361f8293a6bca5a3ec1e82 (diff) |
Ensure buffer for environment is large enough on OpenBSD
-rw-r--r-- | openbsd/Platform.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/openbsd/Platform.c b/openbsd/Platform.c index db9780c2..b222bee0 100644 --- a/openbsd/Platform.c +++ b/openbsd/Platform.c @@ -269,7 +269,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); } @@ -285,6 +291,7 @@ char* Platform_getProcessEnv(pid_t pid) { env[size + 1] = 0; } +end: (void) kvm_close(kt); return env; } |