aboutsummaryrefslogtreecommitdiffstats
path: root/solaris/Platform.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2022-06-03 08:55:21 +0200
committerDaniel Lange <DLange@git.local>2022-06-03 08:55:21 +0200
commitf8c86394f62c6e6f950fcbbff008f639db33241c (patch)
treee82dcf1ba008020628c96661587ed870e0cac179 /solaris/Platform.c
parent4d3dbd693ecd079d5907d81d5d2ff191baa61033 (diff)
parent937052b231259a47d881d539ad5748245ef55b99 (diff)
downloaddebian_htop-f8c86394f62c6e6f950fcbbff008f639db33241c.tar.gz
debian_htop-f8c86394f62c6e6f950fcbbff008f639db33241c.tar.bz2
debian_htop-f8c86394f62c6e6f950fcbbff008f639db33241c.zip
Update upstream source from tag 'upstream/3.2.1'
Update to upstream version '3.2.1' with Debian dir 43b873ddb7f7032e95da61a9cb65eee15c671e73
Diffstat (limited to 'solaris/Platform.c')
-rw-r--r--solaris/Platform.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 20b4d13..9c5acb5 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -267,16 +267,21 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr
envAccum* accump = accum;
(void) Phandle;
(void) addr;
+
size_t thissz = strlen(str);
- if ((thissz + 2) > (accump->capacity - accump->size)) {
- accump->env = xRealloc(accump->env, accump->capacity *= 2);
- }
- if ((thissz + 2) > (accump->capacity - accump->size)) {
- return 1;
+
+ while ((thissz + 2) > (accump->capacity - accump->size)) {
+ if (accump->capacity > (SIZE_MAX / 2))
+ return 1;
+
+ accump->capacity *= 2;
+ accump->env = xRealloc(accump->env, accump->capacity);
}
- strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size));
+
+ strlcpy( accump->env + accump->size, str, accump->capacity - accump->size);
strncpy( accump->env + accump->size + thissz + 1, "\n", 2);
- accump->size = accump->size + thissz + 1;
+
+ accump->size += thissz + 1;
return 0;
}
@@ -299,7 +304,8 @@ char* Platform_getProcessEnv(pid_t pid) {
Prelease(Phandle, 0);
strncpy( envBuilder.env + envBuilder.size, "\0", 1);
- return envBuilder.env;
+
+ return xRealloc(envBuilder.env, envBuilder.size + 1);
}
char* Platform_getInodeFilename(pid_t pid, ino_t inode) {

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