From 0ade23e5752336c4c288dcadc06fc9e4911d3063 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 28 Jan 2019 20:44:20 +0000 Subject: [PATCH] lib: protect termtable from bad fmt string Termtable can write out-of-bounds if given a format string with too many column separators. Signed-off-by: Quentin Young --- lib/termtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/termtable.c b/lib/termtable.c index 4f5f9ff218..01468b8203 100644 --- a/lib/termtable.c +++ b/lib/termtable.c @@ -163,7 +163,7 @@ static struct ttable_cell *ttable_insert_row_va(struct ttable *tt, int i, orig = res; - while (res) { + while (res && col < tt->ncols) { section = strsep(&res, "|"); row[col].text = XSTRDUP(MTYPE_TTABLE, section); row[col].style = tt->style.cell;