mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-14 13:04:35 +03:00
Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail. Abort program cleanly if any of them does.
This commit is contained in:
@ -117,9 +117,9 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
||||
int n = sizeof(buffer) - 1;
|
||||
switch ((int) field) {
|
||||
// add FreeBSD-specific fields here
|
||||
case JID: snprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
||||
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
||||
case JAIL:{
|
||||
snprintf(buffer, n, "%-11s ", fp->jname); break;
|
||||
xSnprintf(buffer, n, "%-11s ", fp->jname); break;
|
||||
if (buffer[11] != '\0') {
|
||||
buffer[11] = ' ';
|
||||
buffer[12] = '\0';
|
||||
|
@ -398,7 +398,7 @@ char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc) {
|
||||
jid = jail_get(jiov, 6, 0);
|
||||
if (jid < 0) {
|
||||
if (!jail_errmsg[0])
|
||||
snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s", strerror(errno));
|
||||
xSnprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s", strerror(errno));
|
||||
return NULL;
|
||||
} else if (jid == kproc->ki_jid) {
|
||||
jname = xStrdup(jnamebuf);
|
||||
|
Reference in New Issue
Block a user