From 7c4894dd222ff951e9b8a7efce00a9d9ab9ee586 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 7 Aug 2013 12:58:57 -0500 Subject: [PATCH] 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 --- ps/output.c | 1 + 1 file changed, 1 insertion(+) 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{ -- 2.40.0