1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-07 15:09:01 +00:00

Avoid clobbering nsiod.peer with junk data if recvfrom doesn't set src_addr

This commit is contained in:
dmiller
2016-05-13 02:13:25 +00:00
parent 50e9080ef1
commit f38b959593
2 changed files with 9 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
# Nmap Changelog ($Id$); -*-text-*-
o [GH#283][Nsock] Avoid "unknown protocol:0" debug messages and an "Unknown
address family 0" crash on Windows and other platforms that do not set the
src_addr argument to recvfrom for TCP sockets. [Daniel Miller]
o [NSE][GH#371] Fix mysql-audit by adding needed library requires to the
mysql-cis.audit file. The script would fail with "Failed to load rulebase"
message. [Paolo Perego]

View File

@@ -644,7 +644,11 @@ static int do_actual_read(struct npool *ms, struct nevent *nse) {
err = socket_errno();
break;
}
if (peerlen > 0) {
/* 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) {
assert(peerlen <= sizeof(iod->peer));
memcpy(&iod->peer, &peer, peerlen);
iod->peerlen = peerlen;