Skip to content

Commit

Permalink
ppp: Fix potential array overflow
Browse files Browse the repository at this point in the history
`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 <securitylab@github.com>
Signed-off-by: Alvaro Muñoz <pwntester@github.com>
Ref IDF-4847
  • Loading branch information
ghsecuritylab authored and david-cermak committed Aug 16, 2022
1 parent 6666694 commit c35e4d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/netif/ppp/eap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit c35e4d3

Please sign in to comment.