summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-13 12:17:18 +0100
committerThomas Haller <thaller@redhat.com>2020-03-16 13:44:12 +0100
commit3d2b982fb758ffc781132b7ebec878b64ea94fa0 (patch)
treed6bd8350db445a564f295c5f6d2db5b69de00cd8
parent5bef7d7453ae050698c888901f57563a8be6df77 (diff)
downloadNetworkManager-3d2b982fb758ffc781132b7ebec878b64ea94fa0.tar.gz
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.
-rw-r--r--clients/cli/utils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index d35ed26631..d8524c55a1 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -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) {