]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: protect termtable from bad fmt string
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 28 Jan 2019 20:44:20 +0000 (20:44 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 28 Jan 2019 20:44:20 +0000 (20:44 +0000)
Termtable can write out-of-bounds if given a format string with too many
column separators.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/termtable.c

index 4f5f9ff218ef724de1e9e40c3b6966b3c21d57ea..01468b820363645e746a3f0ef53753f04b523941 100644 (file)
@@ -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;