Merge pull request #6 from ghsecuritylab/fix/GSL/prevent_rhostname_overflow

[SECURITY] Prevent `rhostname` array overflow
This commit is contained in:
Zachary Tong 2020-03-09 15:05:28 -04:00 committed by GitHub
commit 550db43b89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1445,7 +1445,7 @@ static void eap_request(ppp_pcb *pcb, u_char *inp, int id, int len) {
} }
/* Not so likely to happen. */ /* Not so likely to happen. */
if (vallen >= len + sizeof (rhostname)) { if (len - vallen >= sizeof (rhostname)) {
ppp_dbglog("EAP: trimming really long peer name down"); ppp_dbglog("EAP: trimming really long peer name down");
MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1);
rhostname[sizeof (rhostname) - 1] = '\0'; rhostname[sizeof (rhostname) - 1] = '\0';
@ -1876,7 +1876,7 @@ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) {
} }
/* Not so likely to happen. */ /* Not so likely to happen. */
if (vallen >= len + sizeof (rhostname)) { if (len - vallen >= sizeof (rhostname)) {
ppp_dbglog("EAP: trimming really long peer name down"); ppp_dbglog("EAP: trimming really long peer name down");
MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1);
rhostname[sizeof (rhostname) - 1] = '\0'; rhostname[sizeof (rhostname) - 1] = '\0';