Fix potential pbuf leaks.

This commit is contained in:
marcbou 2007-08-17 22:15:24 +00:00
parent 21b5fb5ddb
commit dbd61d129d
2 changed files with 27 additions and 34 deletions

View File

@ -1624,9 +1624,8 @@ static void pppInput(void *arg)
protocol = ((struct pppInputHeader *)nb->payload)->proto;
if(pbuf_header(nb, -(int)sizeof(struct pppInputHeader))) {
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
return;
goto drop;
}
#if LINK_STATS
@ -1654,10 +1653,8 @@ static void pppInput(void *arg)
* Clip off the VJ header and prepend the rebuilt TCP/IP header and
* pass the result to IP.
*/
if (vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) {
if (pppControl[pd].netif.input != NULL) {
if ((vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) && (pppControl[pd].netif.input)) {
pppControl[pd].netif.input(nb, &pppControl[pd].netif);
}
return;
}
/* Something's wrong so drop it. */
@ -1674,10 +1671,8 @@ static void pppInput(void *arg)
* Process the TCP/IP header for VJ header compression and then pass
* the packet to IP.
*/
if (vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) {
if (pppControl[pd].netif.input != NULL) {
if ((vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) && pppControl[pd].netif.input) {
pppControl[pd].netif.input(nb, &pppControl[pd].netif);
}
return;
}
/* Something's wrong so drop it. */
@ -1691,10 +1686,11 @@ static void pppInput(void *arg)
break;
case PPP_IP: /* Internet Protocol */
PPPDEBUG((LOG_INFO, "pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len));
if (pppControl[pd].netif.input != NULL) {
if (pppControl[pd].netif.input) {
pppControl[pd].netif.input(nb, &pppControl[pd].netif);
}
return;
}
break;
default:
{
struct protent *protp;
@ -1715,7 +1711,6 @@ static void pppInput(void *arg)
/* No handler for this protocol so reject the packet. */
PPPDEBUG((LOG_INFO, "pppInput[%d]: rejecting unsupported proto 0x%04X len=%d\n", pd, protocol, nb->len));
if (pbuf_header(nb, sizeof(protocol))) {
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
goto drop;
}

View File

@ -593,7 +593,6 @@ int vj_uncompress_tcp(
np = pbuf_alloc(PBUF_RAW, n0->len + cs->cs_hlen, PBUF_POOL);
if(!np) {
PPPDEBUG((LOG_WARNING, "vj_uncompress_tcp: realign failed\n"));
*nb = NULL;
goto bad;
}
@ -624,7 +623,6 @@ int vj_uncompress_tcp(
np = pbuf_alloc(PBUF_RAW, cs->cs_hlen, PBUF_POOL);
if(!np) {
PPPDEBUG((LOG_WARNING, "vj_uncompress_tcp: prepend failed\n"));
*nb = NULL;
goto bad;
}
pbuf_cat(np, n0);