Fix off-by-one errors in range checks of state machine states & events.

Found by:       FlexeLint
This commit is contained in:
Poul-Henning Kamp 2003-05-31 18:54:02 +00:00
parent 5eed219cef
commit 04d0f26703
2 changed files with 8 additions and 8 deletions

View File

@ -230,12 +230,12 @@ void i4b_next_l2state(l2_softc_t *l2sc, int event)
panic("i4b_l2fsm.c: event >= N_EVENTS\n");
/* get current state and check it */
if((currstate = l2sc->Q921_state) > N_STATES) /* failsafe */
panic("i4b_l2fsm.c: currstate > N_STATES\n");
if((currstate = l2sc->Q921_state) >= N_STATES) /* failsafe */
panic("i4b_l2fsm.c: currstate >= N_STATES\n");
/* get new state and check it */
if((newstate = l2state_tab[event][currstate].newstate) > N_STATES)
panic("i4b_l2fsm.c: newstate > N_STATES\n");
if((newstate = l2state_tab[event][currstate].newstate) >= N_STATES)
panic("i4b_l2fsm.c: newstate >= N_STATES\n");
if(newstate != ST_SUBSET)

View File

@ -211,13 +211,13 @@ void next_l3state(call_desc_t *cd, int event)
{
int currstate, newstate;
if(event > N_EVENTS)
panic("i4b_l3fsm.c: event > N_EVENTS\n");
if(event >= N_EVENTS)
panic("i4b_l3fsm.c: event >= N_EVENTS\n");
currstate = cd->Q931state;
if(currstate > N_STATES)
panic("i4b_l3fsm.c: currstate > N_STATES\n");
if(currstate >= N_STATES)
panic("i4b_l3fsm.c: currstate >= N_STATES\n");
newstate = l3state_tab[event][currstate].newstate;