fixed bug #38066 Raw pcbs can alter packet without eating it: added assertion to check that p->payload is unchanged

This commit is contained in:
Simon Goldschmidt 2013-01-11 21:59:26 +01:00
parent d237ec7e78
commit 769b2a3e30
2 changed files with 10 additions and 0 deletions

View File

@ -80,6 +80,9 @@ HISTORY
++ Bugfixes:
2013-01-11: Simon Goldschmidt
* raw.c: fixed bug #38066 Raw pcbs can alter packet without eating it
2012-09-26: Simon Goldschmidt
* api_msg.c: fixed bug #37405 'err_tcp()' uses already freed 'netconn' object

View File

@ -119,6 +119,9 @@ raw_input(struct pbuf *p, struct netif *inp)
{
/* receive callback function available? */
if (pcb->recv.ip4 != NULL) {
#ifndef LWIP_NOASSERT
void* old_payload = p->payload;
#endif
/* the receive callback function did not eat the packet? */
eaten = pcb->recv.ip4(pcb->recv_arg, pcb, p, ip_current_src_addr());
if (eaten != 0) {
@ -132,6 +135,10 @@ raw_input(struct pbuf *p, struct netif *inp)
pcb->next = raw_pcbs;
raw_pcbs = pcb;
}
} else {
/* sanity-check that the receive callback did not alter the pbuf */
LWIP_ASSERT("raw pcb recv callback altered pbuf payload pointer without eating packet",
p->payload == old_payload);
}
}
/* no receive callback function was set for this raw PCB */