Harald Welte has submitted this change and it was merged.

Change subject: ensure VTY commands don't segfault if an FSM has no event names
......................................................................


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
---
M src/vty/fsm_vty.c
1 file changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/vty/fsm_vty.c b/src/vty/fsm_vty.c
index 2947678..8628d15 100644
--- a/src/vty/fsm_vty.c
+++ b/src/vty/fsm_vty.c
@@ -61,10 +61,14 @@
        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++) {

-- 
To view, visit https://gerrit.osmocom.org/6950
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I87457945a7b76aa052305c9c531722be1ea0c1d1
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder

Reply via email to