Added pbuf_alloc() return value checks in ip_frag().

This commit is contained in:
christiaans 2006-03-03 11:25:36 +00:00
parent 11a820458f
commit 61dc2e7dd5
2 changed files with 17 additions and 6 deletions

View File

@ -17,6 +17,10 @@ FUTURE
HISTORY HISTORY
2006-03-03 Christiaan Simons
* ipv4/ip_frag.c: Added bound-checking assertions on ip_reassbitmap
access and added pbuf_alloc() return value checks.
2006-01-01 Leon Woestenberg <leon.woestenberg@gmx.net> 2006-01-01 Leon Woestenberg <leon.woestenberg@gmx.net>
* tcp_{in,out}.c, tcp_out.c: Removed 'even sndbuf' fix in TCP, which is * tcp_{in,out}.c, tcp_out.c: Removed 'even sndbuf' fix in TCP, which is
now handled by the checksum routine properly. now handled by the checksum routine properly.

View File

@ -304,6 +304,9 @@ ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest)
/* Get a RAM based MTU sized pbuf */ /* Get a RAM based MTU sized pbuf */
rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF); rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF);
if (rambuf == NULL) {
return ERR_MEM;
}
rambuf->tot_len = rambuf->len = mtu; rambuf->tot_len = rambuf->len = mtu;
rambuf->payload = MEM_ALIGN((void *)buf); rambuf->payload = MEM_ALIGN((void *)buf);
@ -347,11 +350,15 @@ ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest)
* worked would make things simpler. * worked would make things simpler.
*/ */
header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM);
if (header != NULL) {
pbuf_chain(header, rambuf); pbuf_chain(header, rambuf);
netif->output(netif, header, dest); netif->output(netif, header, dest);
IPFRAG_STATS_INC(ip_frag.xmit); IPFRAG_STATS_INC(ip_frag.xmit);
pbuf_free(header); pbuf_free(header);
} else {
pbuf_free(rambuf);
return ERR_MEM;
}
left -= cop; left -= cop;
} }
pbuf_free(rambuf); pbuf_free(rambuf);