Skip to content

Commit

Permalink
pppd: 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>
  • Loading branch information
paulusmack committed Feb 3, 2020
1 parent 858976b commit 8d7970b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pppd/eap.c
Expand Up @@ -1420,7 +1420,7 @@ int len;
}

/* Not so likely to happen. */
if (vallen >= len + sizeof (rhostname)) {
if (len - vallen >= sizeof (rhostname)) {
dbglog("EAP: trimming really long peer name down");
BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
rhostname[sizeof (rhostname) - 1] = '\0';
Expand Down Expand Up @@ -1846,7 +1846,7 @@ int len;
}

/* Not so likely to happen. */
if (vallen >= len + sizeof (rhostname)) {
if (len - vallen >= sizeof (rhostname)) {
dbglog("EAP: trimming really long peer name down");
BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
rhostname[sizeof (rhostname) - 1] = '\0';
Expand Down

0 comments on commit 8d7970b

Please sign in to comment.