All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] logger: remove trailing spaces when outputing to journal
@ 2016-07-18 20:34 Sami Kerola
  2016-07-18 20:49 ` Sami Kerola
  0 siblings, 1 reply; 3+ messages in thread
From: Sami Kerola @ 2016-07-18 20:34 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.

Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".

Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/logger.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 9f2940c..6251f96 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -341,14 +341,10 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp)
 	for (lines = 0; /* nothing */ ; lines++) {
 		buf = NULL;
 		sz = getline(&buf, &dummy, fp);
-		if (sz == -1) {
+		if (sz == -1 && (sz = rtrim_whitespace(buf)) != 0) {
 			free(buf);
 			break;
 		}
-		if (0 < sz && buf[sz - 1] == '\n') {
-			sz--;
-			buf[sz] = '\0';
-		}
 		if (lines == vectors) {
 			vectors *= 2;
 			if (IOV_MAX < vectors)
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-19  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 20:34 [PATCH] logger: remove trailing spaces when outputing to journal Sami Kerola
2016-07-18 20:49 ` Sami Kerola
2016-07-19  9:10   ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.