From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH] logger: remove trailing spaces when outputing to journal
Date: Mon, 18 Jul 2016 21:34:57 +0100 [thread overview]
Message-ID: <20160718203457.3911-1-kerolasa@iki.fi> (raw)
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
next reply other threads:[~2016-07-18 20:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 20:34 Sami Kerola [this message]
2016-07-18 20:49 ` [PATCH] logger: remove trailing spaces when outputing to journal Sami Kerola
2016-07-19 9:10 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160718203457.3911-1-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox