[Swan-dev] pluto: Fix ipsec whack --status crash

Herbert Xu herbert at gondor.apana.org.au
Thu Apr 30 10:17:18 EEST 2015

The current IKEv2 code is prone to generating STATE_UNDEFINED
child states when something goes wrong (e.g., no proposal chosen).
So we best not crash when encountering such states.
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

diff --git a/programs/pluto/state.c b/programs/pluto/state.c
index acbf0c7..a720845 100644
--- a/programs/pluto/state.c
+++ b/programs/pluto/state.c
@@ -1590,7 +1590,8 @@ void fmt_state(struct state *st, const monotime_t n,
 		 c->name, inst,
 		 enum_name(&state_names, st->st_state),
-		 state_story[st->st_state - STATE_MAIN_R0],
+		 st->st_state == STATE_UNDEFINED ?
+			 "" : state_story[st->st_state - STATE_MAIN_R0],
 		 st->st_event ? enum_name(&timer_event_names,
 					  st->st_event->ev_type) : "none",
Email: Herbert Xu <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

More information about the Swan-dev mailing list