diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-05-19 19:58:55 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2021-05-20 16:43:40 +0200 |
commit | 013d2efa519c79a300da9602e6cd599872c25ff7 (patch) | |
tree | beef88e9c74ae6ac86752b92cfff51f618df38d5 /solaris | |
parent | 27be880d0f0dab61b212f76a83e4319ace97797a (diff) |
Solaris: correct process env memory handling
Allow strncpy to NUL-terminate the buffer and do not return a non free-
able string literal.
Diffstat (limited to 'solaris')
-rw-r--r-- | solaris/Platform.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c index 1d4568a0..c2ef2773 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -259,7 +259,7 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr return 1; } strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size)); - strncpy( accump->env + accump->size + thissz + 1, "\n", 1); + strncpy( accump->env + accump->size + thissz + 1, "\n", 2); accump->size = accump->size + thissz + 1; return 0; } @@ -271,7 +271,7 @@ char* Platform_getProcessEnv(pid_t pid) { struct ps_prochandle* Phandle; if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) { - return "Unable to read process environment."; + return NULL; } envBuilder.capacity = 4096; |