Skip to content

Commit

Permalink
PPP, EAP: fix bounds check in EAP code
Browse files Browse the repository at this point in the history
Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sylvain Rochet <gradator@gradator.net> (compiler warning fix about int vs uint comparisons)
  • Loading branch information
paulusmack authored and gradator committed Feb 10, 2020
1 parent 5e52d1a commit 2ee3cbe
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 >= (int)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 >= (int)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 2ee3cbe

Please sign in to comment.