From ab6e265950d447cd143cef40a340daac81fe0127 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Mon, 3 Feb 2020 15:53:28 +1100 Subject: [PATCH] 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 Signed-off-by: Paul Mackerras --- pppd/eap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pppd/eap.c b/pppd/eap.c index 99fb0d9..6309e1b 100644 --- a/pppd/eap.c +++ b/pppd/eap.c @@ -1661,7 +1661,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'; @@ -2251,7 +2251,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'; -- 1.8.3.1