From f7d5e81130ce59a9060203d833365d8071c927a0 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 1 Mar 2015 00:34:00 +0100 Subject: [PATCH] PPP, SERVER, MSCHAP: move output message from chap_server.message struct to stack chap_server.message is only used in one function, moved to stack. --- src/include/netif/ppp/chap-new.h | 1 - src/netif/ppp/chap-new.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/include/netif/ppp/chap-new.h b/src/include/netif/ppp/chap-new.h index d2cc7dee..c0bf024e 100644 --- a/src/include/netif/ppp/chap-new.h +++ b/src/include/netif/ppp/chap-new.h @@ -165,7 +165,6 @@ typedef struct chap_server_state { int challenge_xmits; int challenge_pktlen; unsigned char challenge[CHAL_MAX_PKTLEN]; - char message[256]; } chap_server_state; #endif /* PPP_SERVER */ #endif /* CHAP_SUPPORT */ diff --git a/src/netif/ppp/chap-new.c b/src/netif/ppp/chap-new.c index 7cc4310a..9c9a3e29 100644 --- a/src/netif/ppp/chap-new.c +++ b/src/netif/ppp/chap-new.c @@ -288,6 +288,7 @@ static void chap_handle_response(ppp_pcb *pcb, int id, const unsigned char *, const unsigned char *, char *, int); #endif /* UNUSED */ char rname[MAXNAMELEN+1]; + char message[256]; if ((pcb->chap_server.flags & LOWERUP) == 0) return; @@ -327,7 +328,7 @@ static void chap_handle_response(ppp_pcb *pcb, int id, #endif /* UNUSED */ ok = chap_verify_response(pcb, name, pcb->chap_server.name, id, pcb->chap_server.digest, pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, - response, pcb->chap_server.message, sizeof(pcb->chap_server.message)); + response, message, sizeof(message)); #if 0 /* UNUSED */ if (!ok || !auth_number()) { #endif /* UNUSED */ @@ -339,7 +340,7 @@ static void chap_handle_response(ppp_pcb *pcb, int id, return; /* send the response */ - mlen = strlen(pcb->chap_server.message); + mlen = strlen(message); len = CHAP_HDRLEN + mlen; p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +len), PPP_CTRL_PBUF_TYPE); if(NULL == p) @@ -357,7 +358,7 @@ static void chap_handle_response(ppp_pcb *pcb, int id, outp[2] = len >> 8; outp[3] = len; if (mlen > 0) - memcpy(outp + CHAP_HDRLEN, pcb->chap_server.message, mlen); + memcpy(outp + CHAP_HDRLEN, message, mlen); ppp_write(pcb, p); if (pcb->chap_server.flags & CHALLENGE_VALID) {