diff --git a/CHANGELOG b/CHANGELOG index da614c554..bf9386b81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,9 +28,15 @@ o Fixed a bug in the rDNS system which prevented us from querying certain authoritative DNS servers which have recursion explicitly disabled. Thanks to Doug Hoyte for the patch. +o --packet-trace now reports TCP options (thanks to Zhao Lei for the + patch). + o Cleaned up Nmap DNS reporting to be a little more useful and concise. Thanks to Doug Hoyte for the patch. +o Applied a bunch of small internal cleanup patches by Kris Katterjohn + (kjak(a)ispwest.com). + o Fixed the 'distclean' make target to be more comprehensive. Thanks to Thomas Buchanan (Thomas.Buchanan(a)thecompassgrp.net) for the patch. diff --git a/MACLookup.cc b/MACLookup.cc index 7ff23b1c2..a37042f75 100644 --- a/MACLookup.cc +++ b/MACLookup.cc @@ -153,6 +153,7 @@ void mac_prefix_init() { fp = fopen(filename, "r"); if (!fp) { error("Unable to open %s. Ethernet vendor correlation will not be performed ", filename); + return; } while(fgets(line, sizeof(line), fp)) { diff --git a/idle_scan.cc b/idle_scan.cc index 4d9c1d6ed..1238a9fd6 100644 --- a/idle_scan.cc +++ b/idle_scan.cc @@ -254,8 +254,8 @@ static int ipid_distance(int seqclass , u16 startid, u16 endid) { if (seqclass == IPID_SEQ_BROKEN_INCR) { /* Convert to network byte order */ - startid = (startid >> 8) + ((startid & 0xFF) << 8); - endid = (endid >> 8) + ((endid & 0xFF) << 8); + startid = htons(startid); + endid = htons(endid); return endid - startid; } diff --git a/nmap_tty.cc b/nmap_tty.cc index 9e14ae93c..3ba771ea6 100644 --- a/nmap_tty.cc +++ b/nmap_tty.cc @@ -175,14 +175,12 @@ static int tty_getchar() static void tty_done() { - int fd; - if (!tty_fd) return; - fd = tty_fd; tty_fd = 0; - tcsetattr(fd, TCSANOW, &saved_ti); + tcsetattr(tty_fd, TCSANOW, &saved_ti); - close(fd); + close(tty_fd); + tty_fd = 0; } /* @@ -192,28 +190,26 @@ static void tty_done() */ void tty_init() { - int fd; struct termios ti; - if ((fd = open("/dev/tty", O_RDONLY | O_NONBLOCK)) < 0) return; + if (tty_fd) + return; + + if ((tty_fd = open("/dev/tty", O_RDONLY | O_NONBLOCK)) < 0) return; #ifndef __CYGWIN32__ - if (tcgetpgrp(fd) != getpid()) { - close(fd); return; + if (tcgetpgrp(tty_fd) != getpid()) { + close(tty_fd); return; } #endif - tcgetattr(fd, &ti); - if (tty_fd == 0) - saved_ti = ti; + tcgetattr(tty_fd, &ti); + saved_ti = ti; ti.c_lflag &= ~(ICANON | ECHO); ti.c_cc[VMIN] = 1; ti.c_cc[VTIME] = 0; - tcsetattr(fd, TCSANOW, &ti); + tcsetattr(tty_fd, TCSANOW, &ti); - if (tty_fd == 0) - tty_fd = fd; - atexit(tty_done); } @@ -251,10 +247,10 @@ bool keyWasPressed() log_write(LOG_STDOUT, "Debugging Decreased to %d.\n", o.debugging); } else if (c == 'p') { o.setPacketTrace(true); - log_write(LOG_STDOUT, "Packet Tracing enabled\n."); + log_write(LOG_STDOUT, "Packet Tracing enabled.\n"); } else if (c == 'P') { o.setPacketTrace(false); - log_write(LOG_STDOUT, "Packet Tracing disabled\n."); + log_write(LOG_STDOUT, "Packet Tracing disabled.\n"); } else if (c == '?') { log_write(LOG_STDOUT, "Interactive keyboard commands:\n" diff --git a/osscan2.cc b/osscan2.cc index 4aac586dd..dccf0ee08 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -2841,6 +2841,8 @@ OsScanInfo::OsScanInfo(vector &Targets) { gettimeofday(&now, NULL); + numInitialTargets=0; + /* build up incompleteHosts list */ for(targetno = 0; targetno < Targets.size(); targetno++) { /* check if Targets[targetno] is good to be scanned diff --git a/portlist.cc b/portlist.cc index ffdb0d705..0a14faa30 100644 --- a/portlist.cc +++ b/portlist.cc @@ -268,7 +268,6 @@ int Port::getServiceDeductions(struct serviceDeductions *sd) { char* Port::cstringSanityCheck(const char* string, int len) { char* result; int slen; - unsigned char *p; if(!string) return NULL; @@ -278,10 +277,7 @@ char* Port::cstringSanityCheck(const char* string, int len) { result = (char *) safe_malloc(slen + 1); memcpy(result, string, slen); result[slen] = '\0'; - p = (unsigned char *) result; - while(*p) { - if (!isprint((int)*p)) *p = '.'; - p++; + replacenonprintable(result, strlen(result), '.'); } return result; diff --git a/tcpip.cc b/tcpip.cc index f019aa81a..700991d91 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -714,7 +714,7 @@ void PacketTrace::traceConnect(u8 proto, const struct sockaddr *sock, assert(sin->sin_family == AF_INET6); if (inet_ntop(sin->sin_family, (char *) &sin6->sin6_addr, targetipstr, sizeof(targetipstr)) == NULL) - fatal("Failed to convert target IPv4 address to presentation format!?!"); + fatal("Failed to convert target IPv6 address to presentation format!?!"); targetport = ntohs(sin6->sin6_port); #else assert(0);