diff --git a/FPEngine.cc b/FPEngine.cc index 4b6d09ed4..f75af07fd 100644 --- a/FPEngine.cc +++ b/FPEngine.cc @@ -800,7 +800,7 @@ static double vectorize_isr(std::map& resps) { const char *probe_name; const FPPacket *fp; const TCPHeader *tcp; - std::map::iterator it; + std::map::const_iterator it; probe_name = SEQ_PROBE_NAMES[i]; it = resps.find(probe_name); diff --git a/output.cc b/output.cc index 0f65d58ff..edeb18436 100644 --- a/output.cc +++ b/output.cc @@ -2102,8 +2102,6 @@ void printserviceinfooutput(Target *currenths) { hostname_tbl[i][0] = ostype_tbl[i][0] = devicetype_tbl[i][0] = cpe_tbl[i][0] = '\0'; while ((p = currenths->ports.nextPort(p, &port, TCPANDUDPANDSCTP, PORT_OPEN))) { - std::vector::iterator it; - // The following 2 lines (from portlist.h) tell us that we don't need to // worry about free()ing anything in the serviceDeductions struct. pass in // an allocated struct serviceDeductions (don't worry about initializing, and @@ -2149,7 +2147,7 @@ void printserviceinfooutput(Target *currenths) { } } - for (it = sd.cpe.begin(); it != sd.cpe.end(); it++) { + for (std::vector::const_iterator it = sd.cpe.begin(); it != sd.cpe.end(); it++) { for (i = 0; i < MAX_SERVICE_INFO_FIELDS; i++) { if (cpe_tbl[i][0] && !strcmp(&cpe_tbl[i][0], *it)) break; @@ -2221,7 +2219,7 @@ void printserviceinfooutput(Target *currenths) { #ifndef NOLUA void printscriptresults(ScriptResults *scriptResults, stype scantype) { - ScriptResults::iterator iter; + ScriptResults::const_iterator iter; char *script_output; if (scriptResults->size() > 0) { @@ -2246,7 +2244,7 @@ void printscriptresults(ScriptResults *scriptResults, stype scantype) { } void printhostscriptresults(Target *currenths) { - ScriptResults::iterator iter; + ScriptResults::const_iterator iter; char *script_output; if (currenths->scriptResults.size() > 0) { @@ -2274,7 +2272,7 @@ static void printtraceroute_normal(Target *currenths) { static const int HOP_COL = 0, RTT_COL = 1, HOST_COL = 2; NmapOutputTable Tbl(currenths->traceroute_hops.size() + 1, 3); struct probespec probe; - std::list::iterator it; + std::list::const_iterator it; int row; /* No trace, must be localhost. */ @@ -2314,7 +2312,7 @@ static void printtraceroute_normal(Target *currenths) { if (!o.debugging) { /* Consolidate shared hops. */ - TracerouteHop *shared_hop = NULL; + const TracerouteHop *shared_hop = NULL; struct sockaddr_storage addr; size_t sslen; @@ -2381,7 +2379,7 @@ static void printtraceroute_normal(Target *currenths) { static void printtraceroute_xml(Target *currenths) { struct probespec probe; - std::list::iterator it; + std::list::const_iterator it; /* No trace, must be localhost. */ if (currenths->traceroute_hops.size() == 0) @@ -2401,7 +2399,7 @@ static void printtraceroute_xml(Target *currenths) { xml_attribute("port", "%d", probe.pd.sctp.dport); xml_attribute("proto", "%s", proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_ICMP || probe.type == PS_PROTO) { - struct protoent *proto = nmap_getprotbynum(probe.proto); + const struct protoent *proto = nmap_getprotbynum(probe.proto); if (proto == NULL) xml_attribute("proto", "%d", probe.proto); else @@ -2608,8 +2606,8 @@ struct data_file_record { were found. */ void printdatafilepaths() { std::list df; - std::list::iterator iter; - std::map::iterator map_iter; + std::list::const_iterator iter; + std::map::const_iterator map_iter; std::string dir; unsigned int num_dirs; diff --git a/portreasons.cc b/portreasons.cc index b91132376..5c80abbc6 100644 --- a/portreasons.cc +++ b/portreasons.cc @@ -157,7 +157,7 @@ reason_map_type reason_map; /* Function to Translate ICMP codes and types to * * Reason Codes */ -static const reason_codes icmpv4_to_reason(int icmp_type, int icmp_code) { +static reason_codes icmpv4_to_reason(int icmp_type, int icmp_code) { switch(icmp_type){ @@ -200,7 +200,7 @@ static const reason_codes icmpv4_to_reason(int icmp_type, int icmp_code) { return ER_UNKNOWN; }; -static const reason_codes icmpv6_to_reason(int icmp_type, int icmp_code) { +static reason_codes icmpv6_to_reason(int icmp_type, int icmp_code) { switch(icmp_type){ @@ -235,7 +235,7 @@ static const reason_codes icmpv6_to_reason(int icmp_type, int icmp_code) { return ER_UNKNOWN; }; -const reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code) { +reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code) { if (proto == IPPROTO_ICMP) return icmpv4_to_reason(icmp_type, icmp_code); else if (proto == IPPROTO_ICMPV6) diff --git a/portreasons.h b/portreasons.h index 5111463d9..ed7f0cde9 100644 --- a/portreasons.h +++ b/portreasons.h @@ -146,7 +146,7 @@ public: }; /* Function to translate ICMP code and typ to reason code */ -const reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code); +reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code); /* Passed to reason_str to determine if string should be in * plural of singular form */ diff --git a/services.cc b/services.cc index eab164057..9ae670194 100644 --- a/services.cc +++ b/services.cc @@ -208,7 +208,7 @@ static int nmap_services_init() { ps.proto = proto; /* Now we make sure our service table doesn't have duplicates */ - std::map::iterator i; + std::map::const_iterator i; i = service_table.find(ps); if (i != service_table.end()) { if (o.debugging) @@ -270,15 +270,15 @@ void free_services() { * Returns the number of ports added in total. */ -int addportsfromservmask(char *mask, u8 *porttbl, int range_type) { - std::map::iterator i; +int addportsfromservmask(const char *mask, u8 *porttbl, int range_type) { + std::map::const_iterator i; int t = 0; if (!services_initialized && nmap_services_init() == -1) fatal("%s: Couldn't get port numbers", __func__); for (i = service_table.begin(); i != service_table.end(); i++) { - service_node& current = i->second; + const service_node& current = i->second; if (wildtest(mask, current.s_name)) { if ((range_type & SCAN_TCP_PORT) && strcmp(current.s_proto, "tcp") == 0) { porttbl[current.s_port] |= SCAN_TCP_PORT; @@ -368,7 +368,7 @@ static bool is_port_member(const struct scan_lists *ptsdata, const struct servic // This function doesn't support IP protocol scan so only call this // function if o.TCPScan() || o.UDPScan() || o.SCTPScan() -void gettoppts(double level, char *portlist, struct scan_lists * ports, char *exclude_ports) { +void gettoppts(double level, const char *portlist, struct scan_lists * ports, const char *exclude_ports) { int ti=0, ui=0, si=0; struct scan_lists ptsdata = { 0 }; bool ptsdata_initialized = false; diff --git a/services.h b/services.h index 17f1e1e06..b37560e02 100644 --- a/services.h +++ b/services.h @@ -74,9 +74,9 @@ #define SERVICE_TABLE_SIZE 1024 -int addportsfromservmask(char *mask, u8 *porttbl, int range_type); +int addportsfromservmask(const char *mask, u8 *porttbl, int range_type); struct servent *nmap_getservbyport(int port, const char *proto); -void gettoppts(double level, char *portlist, struct scan_lists * ports, char *exclude_list = NULL); +void gettoppts(double level, const char *portlist, struct scan_lists * ports, const char *exclude_list = NULL); void free_services(); diff --git a/utils.cc b/utils.cc index 99ee3b02c..d2425e530 100644 --- a/utils.cc +++ b/utils.cc @@ -80,7 +80,7 @@ extern NmapOps o; /* Test a wildcard mask against a test string. Wildcard mask can include '*' and '?' which work the same as they do in /bin/sh (except it's case insensitive). Return val of 1 means it DID match. 0 means it DIDN'T. - Doug Hoyte, 2005 */ -int wildtest(char *wild, char *test) { +int wildtest(const char *wild, const char *test) { int i; while (*wild != '\0' || *test != '\0') { diff --git a/utils.h b/utils.h index 4567f40f1..8404d79ba 100644 --- a/utils.h +++ b/utils.h @@ -100,7 +100,7 @@ template T box(T bmin, T bmax, T bnum) { return bnum; } -int wildtest(char *wild, char *test); +int wildtest(const char *wild, const char *test); void nmap_hexdump(const unsigned char *cp, unsigned int length);