Blob Blame History Raw
From 6223d199114c40053be2b1efd2dd735c3a22b26c Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Thu, 19 Jul 2012 21:12:16 +0000
Subject: [PATCH] journalctl: fix assertion failure in ellipsize_mem()

When showing the journal through "journalctl --no-pager", if the
prefix of the log message (i.e. the date and syslog identifier) is
less than 3 characters shorter than the width of the terminal, you
get:

Assertion 'new_length >= 3' failed at src/shared/util.c:3859, function ellipsize_mem(). Aborting.

because there is not enough space for the "...".  This patch add the
necessary check.
(cherry picked from commit b61a4660fcfb76f062c081110fb18424b0bb7b23)
---
 src/shared/logs-show.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index c4731a2..6bc24fa 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -231,7 +231,7 @@ static int output_short(sd_journal *j, unsigned line, unsigned n_columns, bool s
                 printf(": [%s blob data]\n", format_bytes(bytes, sizeof(bytes), message_len));
         } else if (message_len + n < n_columns)
                 printf(": %.*s\n", (int) message_len, message);
-        else if (n < n_columns) {
+        else if (n < n_columns && n_columns - n - 2 >= 3) {
                 char *e;
 
                 e = ellipsize_mem(message, message_len, n_columns - n - 2, 90);