From 9dec0605019ecdc5e4f7206bd7a5bad68313e886 Mon Sep 17 00:00:00 2001 From: Github Security Lab Date: Sun, 8 Mar 2020 12:20:40 +0100 Subject: [PATCH] `vallen` is verified to be less than `len`, therefore, it can never be the case that `vallen >= len + sizeof(rhostname)`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes the check so the `rhostname` array does not overflow. Reported-by: Github Security Lab Signed-off-by: Alvaro Muñoz --- ngos/JWNR2000_4EMRUS/SW/opensource/ppp/pppd/eap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngos/JWNR2000_4EMRUS/SW/opensource/ppp/pppd/eap.c b/ngos/JWNR2000_4EMRUS/SW/opensource/ppp/pppd/eap.c index 6a50a599e..c44c0018a 100755 --- a/ngos/JWNR2000_4EMRUS/SW/opensource/ppp/pppd/eap.c +++ b/ngos/JWNR2000_4EMRUS/SW/opensource/ppp/pppd/eap.c @@ -1421,7 +1421,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'; @@ -1847,7 +1847,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';