1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Allow nsock_iod_get_communication_info() to get latest UDP peer

This commit is contained in:
dmiller
2024-07-01 16:17:42 +00:00
parent ba4a108868
commit dde9c509ed

View File

@@ -638,11 +638,15 @@ static int do_actual_read(struct npool *ms, struct nevent *nse) {
err = socket_errno();
}
else {
if (peerlen > 0
#ifdef WIN32
/* Windows will ignore src_addr and addrlen arguments to recvfrom on TCP
* sockets, so peerlen is still sizeof(peer) and peer is junk. Instead,
* only set this if it's not already set.
*/
if (peerlen > 0 && iod->peerlen == 0) {
&& (iod->lastproto == IPPROTO_UDP || iod->peerlen == 0)
#endif
) {
assert(peerlen <= sizeof(iod->peer));
memcpy(&iod->peer, &peer, peerlen);
iod->peerlen = peerlen;