java-topology/defects/nmap/patch/nmap-0001.patch

53 lines
1.7 KiB
Diff

--- a/service_scan.h
+++ b/service_scan.h
@@ -280,8 +280,8 @@ class ServiceProbe {
std::vector<ServiceProbeMatch *> matches; // first-ever use of STL in Nmap!
char *fallbackStr;
ServiceProbe *fallbacks[MAXFALLBACKS+1];
- std::vector<u16> probableports;
- std::vector<u16> probablesslports;
- std::vector<const char *> detectedServices;
+ std::unordered_set<u16> probableports;
+ std::unordered_set<u16> probablesslports;
+ std::unordered_set<std::string> detectedServices;
--- a/service_scan.cc
+++ b/service_scan.cc
@@ -1,6 +1,7 @@
#include "service_scan.h"
+#include <unordered_set>
@@ -1215,7 +1215,7 @@ void ServiceProbe::setPortVector(std::vector<u16> *portv, const char *portstr,
/* Now I have a rangestart and a rangeend, so I can add these ports */
while(rangestart <= rangeend) {
- portv->push_back(rangestart);
+ portv->insert(rangestart);
rangestart++;
}
@@ -1254,10 +1254,9 @@ bool ServiceProbe::portIsProbable(enum service_tunnel_type tunnel, u16 portno) c
const std::vector<u16> *portv;
-
portv = (tunnel == SERVICE_TUNNEL_SSL)? &probablesslports : &probableports;
-
- if (find(portv->begin(), portv->end(), portno) == portv->end())
+ if (portv->find(portno) == portv->end())
return false;
return true;
}
@@ -1266,10 +1266,8 @@ bool ServiceProbe::serviceIsPossible(const char *sname) const {
- std::vector<const char *>::const_iterator vi;
-
- for(vi = detectedServices.begin(); vi != detectedServices.end(); vi++) {
- if (strcmp(*vi, sname) == 0)
- return true;
- }
- return false;
+ return detectedServices.count(sname) > 0;
}
@@ -1301,7 +1301,7 @@ void ServiceProbe::addService(const char *sname) {
- detectedServices.push_back(sname);
+ detectedServices.insert(sname);
}