[PATCH] libosmocore[master]: ensure VTY commands don't segfault if an FSM has no event names

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Mon Feb 26 18:04:22 UTC 2018


Review at  https://gerrit.osmocom.org/6950

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(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/50/6950/1

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: newchange
Gerrit-Change-Id: I87457945a7b76aa052305c9c531722be1ea0c1d1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>



More information about the gerrit-log mailing list