From: Jim Warner Date: Wed, 7 Aug 2013 17:58:57 +0000 (-0500) Subject: ps: address a potential 'newline' quirk the libselinux X-Git-Tag: v3.3.9~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c4894dd222ff951e9b8a7efce00a9d9ab9ee586;p=procps-ng ps: address a potential 'newline' quirk the libselinux Sometimes with libselinux present but SELinux inactive the context reported is "unconfined" which contains an embedded newline. This then causes misalignment of any subsequent data. So, ps will now protect against that. Reference(s): http://www.freelists.org/post/procps/enablelibselinux-switch,14 Signed-off-by: Jim Warner --- diff --git a/ps/output.c b/ps/output.c index b7b21d15..d457a89c 100644 --- a/ps/output.c +++ b/ps/output.c @@ -1339,6 +1339,7 @@ static int pr_context(char *restrict const outbuf, const proc_t *restrict const len = strlen(context); if(len > max_len) len = max_len; memcpy(outbuf, context, len); + if (outbuf[len-1] == '\n') --len; outbuf[len] = '\0'; free(context); }else{