From cc81722736c9bd2a0a16cf2247eda6b82074a198 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Mon, 26 Feb 2018 19:02:30 +0100 Subject: ensure VTY commands don't segfault if an FSM has no event names If no event names are defined for an FSM, show a placeholder message which points out the problem instead of segfaulting. Change-Id: I87457945a7b76aa052305c9c531722be1ea0c1d1 Related: OS#3007 --- src/vty/fsm_vty.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vty/fsm_vty.c b/src/vty/fsm_vty.c index 2947678b..8628d159 100644 --- a/src/vty/fsm_vty.c +++ b/src/vty/fsm_vty.c @@ -61,10 +61,14 @@ void vty_out_fsm(struct vty *vty, struct osmo_fsm *fsm) vty_out(vty, "FSM Name: '%s', Log Subsys: '%s'%s", fsm->name, log_category_name(fsm->log_subsys), VTY_NEWLINE); /* list the events */ - for (evt_name = fsm->event_names; evt_name->str != NULL; evt_name++) { - vty_out(vty, " Event %02u (0x%08x): '%s'%s", evt_name->value, - (1 << evt_name->value), evt_name->str, VTY_NEWLINE); - } + if (fsm->event_names) { + for (evt_name = fsm->event_names; evt_name->str != NULL; evt_name++) { + vty_out(vty, " Event %02u (0x%08x): '%s'%s", evt_name->value, + (1 << evt_name->value), evt_name->str, VTY_NEWLINE); + } + } else + vty_out(vty, " No event names are defined for this FSM! Please fix!%s", VTY_NEWLINE); + /* list the states */ vty_out(vty, " Number of States: %u%s", fsm->num_states, VTY_NEWLINE); for (i = 0; i < fsm->num_states; i++) { -- cgit v1.2.3