From 1e83a72d02929c4e45b53314a20c408a6c0ff795 Mon Sep 17 00:00:00 2001 From: Github Security Lab Date: Sun, 8 Mar 2020 02:43:50 +0100 Subject: [PATCH] `vallen` is verified to be less than `len`, therefore, it can never be the case that `vallen >= len + sizeof(rhostname)`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes the check so the `rhostname` array does not overflow. Reported-by: Github Security Lab Signed-off-by: Alvaro Muñoz --- .../common/network/lwip/lwip_v1.5.0.beta/src/netif/ppp/eap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component/common/network/lwip/lwip_v1.5.0.beta/src/netif/ppp/eap.c b/component/common/network/lwip/lwip_v1.5.0.beta/src/netif/ppp/eap.c index d603c5d..577f50a 100644 --- a/component/common/network/lwip/lwip_v1.5.0.beta/src/netif/ppp/eap.c +++ b/component/common/network/lwip/lwip_v1.5.0.beta/src/netif/ppp/eap.c @@ -1445,7 +1445,7 @@ static void eap_request(ppp_pcb *pcb, u_char *inp, int id, int len) { } /* Not so likely to happen. */ - if (vallen >= len + sizeof (rhostname)) { + if (len - vallen >= sizeof (rhostname)) { ppp_dbglog("EAP: trimming really long peer name down"); MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); rhostname[sizeof (rhostname) - 1] = '\0'; @@ -1876,7 +1876,7 @@ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) { } /* Not so likely to happen. */ - if (vallen >= len + sizeof (rhostname)) { + if (len - vallen >= sizeof (rhostname)) { ppp_dbglog("EAP: trimming really long peer name down"); MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); rhostname[sizeof (rhostname) - 1] = '\0';