mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-26 21:14:09 +00:00
recvfrom accesses freed netbuf.If it's reused in the small window by another thread recvfrom returns bad from info.Patch #1041 by Florian Zschocke
This commit is contained in:
parent
ea6432702f
commit
442f46a1ce
@ -254,6 +254,16 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
|||||||
the supplied memory pointer mem */
|
the supplied memory pointer mem */
|
||||||
netbuf_copy_partial(buf, mem, copylen, sock->lastoffset);
|
netbuf_copy_partial(buf, mem, copylen, sock->lastoffset);
|
||||||
|
|
||||||
|
/* Check to see from where the data was. */
|
||||||
|
if(from != NULL && fromlen != NULL) {
|
||||||
|
addr = netbuf_fromaddr(buf);
|
||||||
|
port = netbuf_fromport(buf);
|
||||||
|
((struct sockaddr_in *)from)->sin_addr.s_addr = addr->addr;
|
||||||
|
((struct sockaddr_in *)from)->sin_port = port;
|
||||||
|
((struct sockaddr_in *)from)->sin_family = AF_INET;
|
||||||
|
*fromlen = sizeof(struct sockaddr_in);
|
||||||
|
}
|
||||||
|
|
||||||
/* If this is a TCP socket, check if there is data left in the
|
/* If this is a TCP socket, check if there is data left in the
|
||||||
buffer. If so, it should be saved in the sock structure for next
|
buffer. If so, it should be saved in the sock structure for next
|
||||||
time around. */
|
time around. */
|
||||||
@ -266,15 +276,6 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
|||||||
netbuf_delete(buf);
|
netbuf_delete(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check to see from where the data was. */
|
|
||||||
if(from != NULL && fromlen != NULL) {
|
|
||||||
addr = netbuf_fromaddr(buf);
|
|
||||||
port = netbuf_fromport(buf);
|
|
||||||
((struct sockaddr_in *)from)->sin_addr.s_addr = addr->addr;
|
|
||||||
((struct sockaddr_in *)from)->sin_port = port;
|
|
||||||
((struct sockaddr_in *)from)->sin_family = AF_INET;
|
|
||||||
*fromlen = sizeof(struct sockaddr_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
return copylen;
|
return copylen;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user