PPP, PPPoE: fix potential out-of-bound if AC cookie is too long

Found by coverity.

Introduced by c0e7d54e37 "Removed 2 mem_mallocs: error string can be a
global variable, include memory for sc_ac_cookie in struct pppoe_softc;
commented out unused code (sc_service_name/sc_concentrator_name)".

Fixes it by bailing out if received AC cookie is to big for us, this
can't really happen anyway.
This commit is contained in:
Sylvain Rochet 2016-07-02 16:20:57 +02:00
parent 7c368b7f36
commit b438a0d6fd

View File

@ -470,6 +470,10 @@ pppoe_disc_input(struct netif *netif, struct pbuf *pb)
break;
case PPPOE_TAG_ACCOOKIE:
if (ac_cookie == NULL) {
if (len > PPPOE_MAX_AC_COOKIE_LEN) {
PPPDEBUG(LOG_DEBUG, ("pppoe: AC cookie is too long: len = %d, max = %d\n", len, PPPOE_MAX_AC_COOKIE_LEN));
goto done;
}
ac_cookie = (u8_t*)pb->payload + off + sizeof(pt);
ac_cookie_len = len;
}