cli: fix out of bounds access in _print_fill()

cols_len might be larger than header_row->len. That is when
the cols has entries that are not leaf entries (which currently
I think is never the case).

Fix it to use the right variable for the length of the row.
This commit is contained in:
Thomas Haller
2020-03-13 12:17:18 +01:00
parent 5bef7d7453
commit 3d2b982fb7

View File

@@ -1140,7 +1140,8 @@ _print_fill (const NmcConfig *nmc_config,
header_cell->width = nmc_string_screen_width (header_cell->title, NULL);
for (i_row = 0; i_row < targets_len; i_row++) {
const PrintDataCell *cell = &g_array_index (cells, PrintDataCell, i_row * cols_len + i_col);
const PrintDataCell *cells_line = &g_array_index (cells, PrintDataCell, i_row * header_row->len);
const PrintDataCell *cell = &cells_line[i_col];
const char *const*i_strv;
switch (cell->text_format) {