From a8ee55630698406bc6e0a224451386176a07643f Mon Sep 17 00:00:00 2001 From: Github Security Lab Date: Sun, 8 Mar 2020 12:39:53 +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 --- external/lwip/src/netif/ppp/eap.c | 4 ++-- nRF5_SDK_14.2.0_17b948a/external/lwip/src/netif/ppp/eap.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/external/lwip/src/netif/ppp/eap.c b/external/lwip/src/netif/ppp/eap.c index 8fb56368..971f58b9 100644 --- a/external/lwip/src/netif/ppp/eap.c +++ b/external/lwip/src/netif/ppp/eap.c @@ -1417,7 +1417,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'; @@ -1845,7 +1845,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'; diff --git a/nRF5_SDK_14.2.0_17b948a/external/lwip/src/netif/ppp/eap.c b/nRF5_SDK_14.2.0_17b948a/external/lwip/src/netif/ppp/eap.c index 8fb56368..971f58b9 100644 --- a/nRF5_SDK_14.2.0_17b948a/external/lwip/src/netif/ppp/eap.c +++ b/nRF5_SDK_14.2.0_17b948a/external/lwip/src/netif/ppp/eap.c @@ -1417,7 +1417,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'; @@ -1845,7 +1845,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';