PPP: assert if ppp_set_* functions are called when session is not dead

ppp_set_* functions that set the PPP session parameters must only be
called when the session is in a dead state (i.e. disconnected),
otherwise not fatal but surprising results may happen.
This commit is contained in:
Sylvain Rochet 2020-10-21 02:11:59 +02:00 committed by Simon Goldschmidt
parent 7e92fb3d7f
commit 018c64ab94

View File

@ -216,6 +216,8 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
/***********************************/ /***********************************/
#if PPP_AUTH_SUPPORT #if PPP_AUTH_SUPPORT
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) { void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) {
LWIP_ASSERT("pcb->phase == PPP_PHASE_DEAD", pcb->phase == PPP_PHASE_DEAD);
#if PAP_SUPPORT #if PAP_SUPPORT
pcb->settings.refuse_pap = !(authtype & PPPAUTHTYPE_PAP); pcb->settings.refuse_pap = !(authtype & PPPAUTHTYPE_PAP);
#endif /* PAP_SUPPORT */ #endif /* PAP_SUPPORT */
@ -237,6 +239,8 @@ void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *pas
#if MPPE_SUPPORT #if MPPE_SUPPORT
/* Set MPPE configuration */ /* Set MPPE configuration */
void ppp_set_mppe(ppp_pcb *pcb, u8_t flags) { void ppp_set_mppe(ppp_pcb *pcb, u8_t flags) {
LWIP_ASSERT("pcb->phase == PPP_PHASE_DEAD", pcb->phase == PPP_PHASE_DEAD);
if (flags == PPP_MPPE_DISABLE) { if (flags == PPP_MPPE_DISABLE) {
pcb->settings.require_mppe = 0; pcb->settings.require_mppe = 0;
return; return;