Diff between 264bf951f2d687f520898fa3e182291f1261e3a7 and fdbfe0018f6f216ff089c0e1db848ec8ae16585e

Changed Files

File Additions Deletions Status
monitor/packet.c +8 -0 modified

Full Patch

diff --git a/monitor/packet.c b/monitor/packet.c
index 2eb5089..b186431 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -490,6 +490,14 @@ static void print_packet(struct timeval *tv, struct ucred *cred, char ident,
 		int extra_len = extra ? strlen(extra) : 0;
 		int max_len = col - len - extra_len - ts_len - 3;
 
+		/* Check if there is enough space for the text and the label, if
+		 * there isn't then discard extra text since it won't fit.
+		 */
+		if (max_len <= 0) {
+			extra = NULL;
+			max_len = col - len - ts_len - 3;
+		}
+
 		n = snprintf(line + pos, max_len + 1, "%s%s",
 						label ? ": " : "", text);
 		if (n > max_len) {