mirror of https://github.com/xzeldon/htop.git
Solaris: correct process env memory handling
Allow strncpy to NUL-terminate the buffer and do not return a non free- able string literal.
This commit is contained in:
parent
27be880d0f
commit
013d2efa51
|
@ -259,7 +259,7 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
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", 1);
|
strncpy( accump->env + accump->size + thissz + 1, "\n", 2);
|
||||||
accump->size = accump->size + thissz + 1;
|
accump->size = accump->size + thissz + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||||
struct ps_prochandle* Phandle;
|
struct ps_prochandle* Phandle;
|
||||||
|
|
||||||
if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) {
|
if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) {
|
||||||
return "Unable to read process environment.";
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
envBuilder.capacity = 4096;
|
envBuilder.capacity = 4096;
|
||||||
|
|
Loading…
Reference in New Issue