Skip to content

Commit 8d7970b

Browse files
committed
pppd: Fix bounds check in EAP code
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 858976b commit 8d7970b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pppd/eap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ int len;
14201420
}
14211421

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

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

0 commit comments

Comments
 (0)