Reverted change for bug #27252 (Address pointer invalid after freeing pbuf in UDP receive callback) as it made more problems than before :-(

This commit is contained in:
goldsimon 2009-10-07 17:50:46 +00:00
parent ddc783bee7
commit 9e5cf1cf8e
3 changed files with 4 additions and 7 deletions

View File

@ -60,10 +60,6 @@ HISTORY
2009-08-23 Simon Goldschmidt 2009-08-23 Simon Goldschmidt
* ppp.c: bug #27266: wait-state debug message in pppMain occurs every ms * ppp.c: bug #27266: wait-state debug message in pppMain occurs every ms
2009-08-23 Simon Goldschmidt
* udp.c: bug #27252: Address pointer invalid after freeing pbuf in UDP
receive callback
2009-08-23 Simon Goldschmidt 2009-08-23 Simon Goldschmidt
* many ppp files: bug #27267: Added include to string.h where needed * many ppp files: bug #27267: Added include to string.h where needed

View File

@ -281,10 +281,8 @@ udp_input(struct pbuf *p, struct netif *inp)
snmp_inc_udpindatagrams(); snmp_inc_udpindatagrams();
/* callback */ /* callback */
if (pcb->recv != NULL) { if (pcb->recv != NULL) {
/* copy the source address to make it independent of the pbuf */
struct ip_addr src_addr = iphdr->src;
/* now the recv function is responsible for freeing p */ /* now the recv function is responsible for freeing p */
pcb->recv(pcb->recv_arg, pcb, p, &src_addr, src); pcb->recv(pcb->recv_arg, pcb, p, &iphdr->src, src);
} else { } else {
/* no recv function registered? then we have to free the pbuf! */ /* no recv function registered? then we have to free the pbuf! */
pbuf_free(p); pbuf_free(p);

View File

@ -94,6 +94,9 @@ struct udp_pcb {
* The callback is responsible for freeing the pbuf * The callback is responsible for freeing the pbuf
* if it's not used any more. * if it's not used any more.
* *
* ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf
* makes 'addr' invalid, too.
*
* @param arg user supplied argument (udp_pcb.recv_arg) * @param arg user supplied argument (udp_pcb.recv_arg)
* @param pcb the udp_pcb which received data * @param pcb the udp_pcb which received data
* @param p the packet buffer that was received * @param p the packet buffer that was received