[systemd-devel] [PATCH] logs-show: fix corrupt output with empty messages

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Feb 26 21:47:19 PST 2014


On Thu, Feb 20, 2014 at 03:00:09AM +0200, Uoti Urpala wrote:
> From 4775218f59474165395f7868dfbf9e6b831f5fee Mon Sep 17 00:00:00 2001
> From: Uoti Urpala <uau at glyph.nonexistent.invalid>
> Date: Thu, 20 Feb 2014 02:31:04 +0200
> Subject: [PATCH] logs-show: fix corrupt output with empty messages
> 
> If a message had zero length, journalctl would print no newline, and
> two output lines would be concatenated. Fix. The problem was
> introduced in commit 31f7bf199452 ("logs-show: print multiline
> messages"). Affected short and verbose output modes.
> 
> Before fix:
> 
> Feb 09 21:16:17 glyph dhclient[1323]: Feb 09 21:16:17 glyph NetworkManager[788]: <info> (enp4s2): DHCPv4 state changed nbi -> preinit
> 
> after:
> 
> Feb 09 21:16:17 glyph dhclient[1323]:
> Feb 09 21:16:17 glyph NetworkManager[788]: <info> (enp4s2): DHCPv4 state changed nbi -> preinit

Applied, though I changed the "fix" to simply print a newline.
Just seems nicer this way.

> I also noticed a minor C correctness problem in print_multiline(): if
> the last line of message has no newline, then end = message+message_len.
> The next loop iteration calculates "pos = end + 1". This means that pos
> points 2 past the last byte, which is not guaranteed to be a valid
> address calculation for general C objects (could theoretically wrap
> around to start of address space etc). Probably won't be called with
> such objects in practice.

Zbyszek


More information about the systemd-devel mailing list