vty: Skip printing non-initialized log categories

Without this patch the vty command show logging vty will cause a segfault if
not all elements of the log_categories array are defined.

Ticket: OW#3053
Sponsored-by: On-Waves ehf
Change-Id: Ieeba649c3bde6c9376d8e32b00b92beb37c08ef2
This commit is contained in:
Daniel Willmann 2016-11-15 10:05:51 +01:00 committed by Harald Welte
parent 8593f1f57a
commit 55363a9f62
1 changed files with 3 additions and 0 deletions

View File

@ -275,6 +275,9 @@ static void vty_print_logtarget(struct vty *vty, const struct log_info *info,
for (i = 0; i < info->num_cat; i++) {
const struct log_category *cat = &tgt->categories[i];
/* Skip categories that were not initialized */
if (!info->cat[i].name)
continue;
vty_out(vty, " %-10s %-10s %-8s %s%s",
info->cat[i].name+1, log_level_str(cat->loglevel),
cat->enabled ? "Enabled" : "Disabled",