summaryrefslogtreecommitdiffstats
path: root/src/vty
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-02-26 19:02:30 +0100
committerHarald Welte <laforge@gnumonks.org>2018-02-26 19:01:10 +0000
commitcc81722736c9bd2a0a16cf2247eda6b82074a198 (patch)
tree5f9e0cf08e0ca46d521536c1f77215af5110f3fe /src/vty
parent888dc7d31aa4b39ba8e08884c39be1c09c92f82a (diff)
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
Diffstat (limited to 'src/vty')
-rw-r--r--src/vty/fsm_vty.c12
1 files 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++) {