From: Craig Small Date: Mon, 27 Aug 2018 11:30:33 +0000 (+1000) Subject: killall: use correct size for comm X-Git-Tag: v23.2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acdcbf30c68053a25a1a5b5a6604a8382912be71;p=psmisc killall: use correct size for comm sizeof only works on statically created pointers, not pointers that are passed as parameters to the function. The referenced commit unfortunately didn't follow this and we got truncated names. Thanks to Hector Martin for pointing the problem out. References: commit 1e2f38a202798a78554ae5f5d12f697f3607f89f psmisc/psmisc#14 --- diff --git a/src/killall.c b/src/killall.c index bbbc187..7f982a1 100644 --- a/src/killall.c +++ b/src/killall.c @@ -350,8 +350,8 @@ load_process_name_and_age(char *comm, double *process_age_sec, lencomm = endcomm - startcomm; if (lencomm < 0) lencomm = 0; - if (lencomm > sizeof comm -1) - lencomm = sizeof comm -1; + if (lencomm > COMM_LEN -1) + lencomm = COMM_LEN -1; strncpy(comm, startcomm, lencomm); comm[lencomm] = '\0';