From 2140dfb00f83bcd7614f673f66b9f2f4240cb7a7 Mon Sep 17 00:00:00 2001 From: fyodor Date: Tue, 29 Aug 2006 04:03:03 +0000 Subject: [PATCH] Applied a patch by Kris Katterjohn which makes 14 functions static --- CHANGELOG | 24 +++++++++++-------- MACLookup.cc | 2 +- nmap_dns.cc | 8 +++---- output.cc | 62 ++++++++++++++++++++++++------------------------- output.h | 1 - service_scan.cc | 18 +++++++------- targets.cc | 20 ++++++++-------- 7 files changed, 69 insertions(+), 66 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2ff703680..00f27808e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,7 +2,9 @@ 4.20ALPHA5 o Worked with Zhao to improve the new OS detection system with - better algorithms, some probe changes, and some bug fixes. + better algorithms, some probe changes, and some bug fixes. We're + now ready to start growing the new database! If Nmap gives you + fingerprints, please submit them at the given URL. o Nmap now supports IP options with the new --ip-options flag. You can specify any optiosn in hex, or use "R" (record route), "T" @@ -13,6 +15,11 @@ o Nmap now supports IP options with the new --ip-options flag. You http://seclists.org/nmap-dev/2006/q3/0052.html . Thanks to Marek Majkowski for writing and sending the patch. +o Integrated all 2nd quarter service detection fingerprint + submissions. Please keep them coming! We now have 3,671 signatures + representing 415 protocols. Thanks to version detection czar Doug + Hoyte for doing this. + o Nmap now uses the (relatively) new libpcap pcap_get_selectable_fd API on systems which support it. This means that we no longer need to hack the included Pcap to better support Linux. So Nmap will now @@ -24,26 +31,23 @@ o Updated the included libpcap from 0.9.3 to 0.9.4. The changes I use the included libpcap unless version 0.9.4 or greater is already installed on the system. -o Applied some nsock bugfixes from Diman Todorov. These don't - affect the current version of Nmap, but are important for his upcoming - Nmap Scripting Engine. +o Applied some nsock bugfixes from Diman Todorov. These don't affect + the current version of Nmap, but are important for his Nmap + Scripting Engine, which I hope to integrate into mainline Nmap in + September. o Fixed a bug which would occasionally cause Nmap to crash with the message "log_vwrite: write buffer not large enough". I thought I conquered it in a previous release -- thanks to Doug Hoyte for finding a corner case which proved me wrong. -o Integrated all 2nd quarter service detection fingerprint - submissions. Please keep them coming! We now have 3,671 signatures - representing 415 protocols. Thanks to version detection czar Doug - Hoyte for doing this. - 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). + patch). Thanks to the --ip-options addition also found in this + release, IP options are printed too. o Cleaned up Nmap DNS reporting to be a little more useful and concise. Thanks to Doug Hoyte for the patch. diff --git a/MACLookup.cc b/MACLookup.cc index a1d3157fa..738eb8712 100644 --- a/MACLookup.cc +++ b/MACLookup.cc @@ -128,7 +128,7 @@ static inline int MACTableHash(int prefix, int table_capacity) { return prefix % table_capacity; } -void mac_prefix_init() { +static void mac_prefix_init() { static int initialized = 0; if (initialized) return; initialized = 1; diff --git a/nmap_dns.cc b/nmap_dns.cc index dbbe2e7f1..440caa3b3 100644 --- a/nmap_dns.cc +++ b/nmap_dns.cc @@ -291,7 +291,7 @@ static ScanProgressMeter *SPM; //------------------- Prototypes and macros --------------------- -void put_dns_packet_on_wire(request *req); +static void put_dns_packet_on_wire(request *req); #define ACTION_FINISHED 0 #define ACTION_CNAME_LIST 1 @@ -391,7 +391,7 @@ static void write_evt_handler(nsock_pool nsp, nsock_event evt, void *req_v) { // Takes a DNS request structure and actually puts it on the wire // (calls nsock_write()). Does various other tasks like recording // the time for the timeout. -void put_dns_packet_on_wire(request *req) { +static void put_dns_packet_on_wire(request *req) { char packet[512]; int plen=0; u32 ip; @@ -593,7 +593,7 @@ static u32 parse_inaddr_arpa(unsigned char *buf, int maxlen) { // Turns a DNS packet encoded name (see the RFC) and turns it into // a normal decimal separated hostname. // ASSUMES NAME LENGTH/VALIDITY HAS ALREADY BEEN VERIFIED -int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){ +static int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){ while (buf[0]) { if (buf[0] >= outputsize-1) return -1; memcpy(output, buf+1, buf[0]); @@ -834,7 +834,7 @@ void free_dns_servers() { // Creates a new nsi for each DNS server -void connect_dns_servers() { +static void connect_dns_servers() { std::list::iterator serverI; dns_server *s; diff --git a/output.cc b/output.cc index 680bc2d40..fef9fdcb8 100644 --- a/output.cc +++ b/output.cc @@ -156,6 +156,37 @@ static void skid_output(char *s) } } +/* Remove all "\nSF:" from fingerprints */ +static char* xml_sf_convert (const char* str) { + char *temp = (char *) safe_malloc(strlen(str) + 1); + char *dst = temp, *src = (char *)str; + char *ampptr = 0; + int charcount = 0; + + while(*src && charcount < 2035) { /* 2048 - 14 */ + if (strncmp(src, "\nSF:", 4) == 0) { + src += 4; + continue; + } + /* Needed so "&something;" is not truncated midway */ + if (*src == '&') { + ampptr = dst; + } + else if (*src == ';') { + ampptr = 0; + } + *dst++ = *src++; + charcount++; + } + if (ampptr != 0) { + *ampptr = '\0'; + } + else { + *dst = '\0'; + } + return temp; +} + // Creates an XML element for the information given in // serviceDeduction. It will be 0-length if none is neccessary. @@ -749,37 +780,6 @@ void log_vwrite(int logt, const char *fmt, va_list ap) { return; } -/* Remove all "\nSF:" from fingerprints */ -char* xml_sf_convert (const char* str) { - char *temp = (char *) safe_malloc(strlen(str) + 1); - char *dst = temp, *src = (char *)str; - char *ampptr = 0; - int charcount = 0; - - while(*src && charcount < 2035) { /* 2048 - 14 */ - if (strncmp(src, "\nSF:", 4) == 0) { - src += 4; - continue; - } - /* Needed so "&something;" is not truncated midway */ - if (*src == '&') { - ampptr = dst; - } - else if (*src == ';') { - ampptr = 0; - } - *dst++ = *src++; - charcount++; - } - if (ampptr != 0) { - *ampptr = '\0'; - } - else { - *dst = '\0'; - } - return temp; -} - /* Write some information (printf style args) to the given log stream(s). Remember to watch out for format string bugs. */ void log_write(int logt, const char *fmt, ...) diff --git a/output.h b/output.h index 3f8c70ba1..bdffaf429 100644 --- a/output.h +++ b/output.h @@ -203,5 +203,4 @@ void printStatusMessage(); void printfinaloutput(); char* xml_convert (const char* str); -char* xml_sf_convert (const char* str); #endif /* OUTPUT_H */ diff --git a/service_scan.cc b/service_scan.cc index f9358362d..112f3f6bc 100644 --- a/service_scan.cc +++ b/service_scan.cc @@ -255,10 +255,10 @@ struct substargs { }; /******************** PROTOTYPES *******************/ -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi); +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi); ServiceProbeMatch::ServiceProbeMatch() { deflineno = -1; @@ -1138,7 +1138,7 @@ void parse_nmap_service_probe_file(AllProbes *AP, char *filename) { // Parses the nmap-service-probes file, and adds each probe to // the already-created 'probes' vector. -void parse_nmap_service_probes(AllProbes *AP) { +static void parse_nmap_service_probes(AllProbes *AP) { char filename[256]; if (nmap_fetchfile(filename, sizeof(filename), "nmap-service-probes") == -1){ @@ -1893,7 +1893,7 @@ static void handleHostIfDone(ServiceGroup *SG, Target *target) { // A simple helper function to cancel further work on a service and // set it to the given probe_state pass NULL for nsi if you don't want // it to be deleted (for example, if you already have done so). -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) { +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) { list::iterator member; Target *target = svc->target; @@ -1982,7 +1982,7 @@ static int launchSomeServiceProbes(nsock_pool nsp, ServiceGroup *SG) { } -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) { nsock_iod nsi = nse_iod(nse); enum nse_status status = nse_status(nse); enum nse_type type = nse_type(nse); @@ -2042,7 +2042,7 @@ void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) return; } -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { enum nse_status status = nse_status(nse); nsock_iod nsi; ServiceNFO *svc = (ServiceNFO *)mydata; @@ -2092,7 +2092,7 @@ void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { return; } -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) { nsock_iod nsi = nse_iod(nse); enum nse_status status = nse_status(nse); enum nse_type type = nse_type(nse); diff --git a/targets.cc b/targets.cc index 5c07b9346..11efffa62 100644 --- a/targets.cc +++ b/targets.cc @@ -887,8 +887,8 @@ static int sendconnecttcpqueries(Target *hostbatch[], struct tcpqueryinfo *tqi, return 0; } -int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port, - u16 seq, struct timeval *time, struct pingtune *pt) { +static int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port, + u16 seq, struct timeval *time, struct pingtune *pt) { int trynum = 0; unsigned short sportbase; @@ -910,8 +910,8 @@ else { return 0; } -int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port, - u16 seq, struct timeval *time, struct pingtune *pt) { +static int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port, + u16 seq, struct timeval *time, struct pingtune *pt) { int trynum = 0; int myseq; unsigned short sportbase; @@ -948,8 +948,8 @@ else { return 0; } -int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, - struct timeval *time, struct pingtune *pt) { +static int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, + struct timeval *time, struct pingtune *pt) { int i; struct eth_nfo eth; struct eth_nfo *ethptr = NULL; @@ -1114,10 +1114,10 @@ static int sendpingqueries(int sd, int rawsd, eth_t *ethsd, Target *target, } -int get_connecttcpscan_results(struct tcpqueryinfo *tqi, - Target *hostbatch[], - struct timeval *time, struct pingtune *pt, - struct timeout_info *to) { +static int get_connecttcpscan_results(struct tcpqueryinfo *tqi, + Target *hostbatch[], + struct timeval *time, struct pingtune *pt, + struct timeout_info *to) { int res, res2; int tm;