mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-08-17 15:30:25 +00:00
ppp: Fix potential array overflow
`vallen` is verified to be less than `len`, therefore, it can never be the case that `vallen >= len + sizeof(rhostname)`. This PR fixes the check so the `rhostname` array does not overflow. Reported-by: Github Security Lab <[email protected]> Signed-off-by: Alvaro Muñoz <[email protected]> Ref IDF-4847
This commit is contained in:
committed by
David Cermak
parent
66666948f9
commit
c35e4d32f9
+2
-2
@@ -1417,7 +1417,7 @@ static void eap_request(ppp_pcb *pcb, u_char *inp, int id, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Not so likely to happen. */
|
/* Not so likely to happen. */
|
||||||
if (vallen >= len + sizeof (rhostname)) {
|
if (len - vallen >= sizeof (rhostname)) {
|
||||||
ppp_dbglog("EAP: trimming really long peer name down");
|
ppp_dbglog("EAP: trimming really long peer name down");
|
||||||
MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1);
|
MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1);
|
||||||
rhostname[sizeof (rhostname) - 1] = '\0';
|
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. */
|
/* Not so likely to happen. */
|
||||||
if (vallen >= len + sizeof (rhostname)) {
|
if (len - vallen >= sizeof (rhostname)) {
|
||||||
ppp_dbglog("EAP: trimming really long peer name down");
|
ppp_dbglog("EAP: trimming really long peer name down");
|
||||||
MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1);
|
MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1);
|
||||||
rhostname[sizeof (rhostname) - 1] = '\0';
|
rhostname[sizeof (rhostname) - 1] = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user