* Fix all uses of pbuf_header to check the return value. In some

cases just assert if it fails as I'm not sure how to fix them, but
    this is no worse than before when they would carry on regardless
    of the failure.
This commit is contained in:
kieranm
2007-03-21 12:55:00 +00:00
parent b422864d5d
commit 7294cb080b
12 changed files with 106 additions and 34 deletions

View File

@@ -1293,10 +1293,14 @@ static void pppInput(void *arg)
u16_t protocol;
int pd;
pd = ((struct pppInputHeader *)nb->payload)->unit;
protocol = ((struct pppInputHeader *)nb->payload)->proto;
pbuf_header(nb, -(int)sizeof(struct pppInputHeader));
pd = ((struct pppInputHeader *)nb->payload)->unit;
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;
}
#if LINK_STATS
lwip_stats.link.recv++;
@@ -1383,7 +1387,11 @@ 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));
pbuf_header(nb, sizeof(protocol));
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;
}
#if BYTE_ORDER == LITTLE_ENDIAN
protocol = htons(protocol);
memcpy(nb->payload, &protocol, sizeof(protocol));

View File

@@ -371,13 +371,19 @@ u_int vj_compress_tcp(
if (!comp->compressSlot || comp->last_xmit != cs->cs_id) {
comp->last_xmit = cs->cs_id;
hlen -= deltaS + 4;
pbuf_header(pb, -hlen);
if(pbuf_header(pb, -hlen)){
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
}
cp = (u_char *)pb->payload;
*cp++ = changes | NEW_C;
*cp++ = cs->cs_id;
} else {
hlen -= deltaS + 3;
pbuf_header(pb, -hlen);
if(pbuf_header(pb, -hlen)) {
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
}
cp = (u_char *)pb->payload;
*cp++ = changes;
}
@@ -573,8 +579,13 @@ int vj_uncompress_tcp(
cs->cs_ip.ip_sum = (u_short)(~tmp);
/* Remove the compressed header and prepend the uncompressed header. */
pbuf_header(n0, -vjlen);
if(pbuf_header(n0, -vjlen)) {
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
goto bad;
}
if(MEM_ALIGN(n0->payload) != n0->payload) {
struct pbuf *np, *q;
u8_t *bufptr;
@@ -586,7 +597,11 @@ int vj_uncompress_tcp(
goto bad;
}
pbuf_header(np, -cs->cs_hlen);
if(pbuf_header(np, -cs->cs_hlen)) {
/* Can we cope with this failing? Just assert for now */
LWIP_ASSERT("pbuf_header failed\n", 0);
goto bad;
}
bufptr = n0->payload;
for(q = np; q != NULL; q = q->next) {