1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-11 10:19:03 +00:00

Remove the "Linux goofiness" zero-byte write test from scan_engine.cc.

See r14426 in /nsock.
This commit is contained in:
david
2009-07-19 04:04:32 +00:00
parent 935d0677da
commit 82a668c278

View File

@@ -3689,51 +3689,39 @@ static bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
case 0: case 0:
#ifdef LINUX #ifdef LINUX
if (!FD_ISSET(sd, &fds_rtmp)) { if (!FD_ISSET(sd, &fds_rtmp)) {
/* Linux goofiness -- We need to actually test that it is writeable */ if (getpeername(sd, (struct sockaddr *) &sin, &sinlen) < 0) {
res = send(sd, "", 0, 0); pfatal("error in getpeername of connect_results for port %hu", (u16) pport);
} else {
if (res < 0 ) { s_in = (struct sockaddr_in *) &sin;
if (o.debugging > 1) { s_in6 = (struct sockaddr_in6 *) &sin;
log_write(LOG_STDOUT, "Bad port %hu caught by 0-byte write: ", if ((o.af() == AF_INET &&
pport); pport != ntohs(s_in->sin_port))
perror("");
}
newportstate = PORT_CLOSED;
} else {
if (getpeername(sd, (struct sockaddr *) &sin, &sinlen) < 0) {
pfatal("error in getpeername of connect_results for port %hu", (u16) pport);
} else {
s_in = (struct sockaddr_in *) &sin;
s_in6 = (struct sockaddr_in6 *) &sin;
if ((o.af() == AF_INET &&
pport != ntohs(s_in->sin_port))
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
|| (o.af() == AF_INET6 && pport != ntohs(s_in6->sin6_port)) || (o.af() == AF_INET6 && pport != ntohs(s_in6->sin6_port))
#endif #endif
) { ) {
error("Mismatch!!!! we think we have port %hu but we really have a different one", (u16) pport); error("Mismatch!!!! we think we have port %hu but we really have a different one", (u16) pport);
} }
} }
if (getsockname(sd, (struct sockaddr *) &sout, &soutlen) < 0) { if (getsockname(sd, (struct sockaddr *) &sout, &soutlen) < 0) {
pfatal("error in getsockname for port %hu", (u16) pport); pfatal("error in getsockname for port %hu", (u16) pport);
} }
s_in = (struct sockaddr_in *) &sout; s_in = (struct sockaddr_in *) &sout;
s_in6 = (struct sockaddr_in6 *) &sout; s_in6 = (struct sockaddr_in6 *) &sout;
if ((o.af() == AF_INET && htons(s_in->sin_port) == pport) if ((o.af() == AF_INET && htons(s_in->sin_port) == pport)
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
|| (o.af() == AF_INET6 && htons(s_in6->sin6_port) == pport) || (o.af() == AF_INET6 && htons(s_in6->sin6_port) == pport)
#endif #endif
) { ) {
/* Linux 2.2 bug can lead to bogus successful connect()ions /* Linux 2.2 bug can lead to bogus successful connect()ions
in this case -- we treat the port as bogus even though it in this case -- we treat the port as bogus even though it
is POSSIBLE that this is a real connection */ is POSSIBLE that this is a real connection */
newportstate = PORT_CLOSED; newportstate = PORT_CLOSED;
} else { } else {
newhoststate = HOST_UP; newhoststate = HOST_UP;
newportstate = PORT_OPEN; newportstate = PORT_OPEN;
} }
}
} else { } else {
newhoststate = HOST_UP; newhoststate = HOST_UP;
newportstate = PORT_OPEN; newportstate = PORT_OPEN;