Limit maxSocketsAllowed to FD_SETSIZE.

At high scan rates, there was nothing to prevent trying to set or clear
socket descriptors above FD_SETSIZE, which is usually around 1024. I got
a reliable assertion failures with the command
	nmap -sT -p- --min-rate 100000 scanme.nmap.org
The problem only affected -sT scans. A similar protection was added to
Nsock in r15808.
This commit is contained in:
david 2013-02-22 01:14:32 +00:00
parent 630a6db051
commit 785855e3ac
2 changed files with 8 additions and 0 deletions

View file

@ -1,5 +1,12 @@
# Nmap Changelog ($Id$); -*-text-*-
o Limited the number of open sockets in ultra_scan to FD_SETSIZE. Very
fast connect scans could write past the end of an fd_set and cause a
variety of crashes:
nmap: scan_engine.cc:978: bool ConnectScanInfo::clearSD(int): Assertion `numSDs > 0' failed.
select failed in do_one_select_round(): Bad file descriptor (9)
[David Fifield]
o Fixed a bug that prevented Nmap from finding any interfaces when one
of them had the type ARP_HDR_APPLETALK; this was the case for
AppleTalk interfaces. However, This support is not complete

View file

@ -960,6 +960,7 @@ ConnectScanInfo::ConnectScanInfo() {
if (maxSocketsAllowed < 5)
maxSocketsAllowed = 5;
}
maxSocketsAllowed = MIN(maxSocketsAllowed, FD_SETSIZE - 10);
FD_ZERO(&fds_read);
FD_ZERO(&fds_write);
FD_ZERO(&fds_except);