# UNDF: UNDF-2026-000000187 --- a/service_scan.h +++ b/service_scan.h @@ -280,8 +280,8 @@ class ServiceProbe { std::vector matches; // first-ever use of STL in Nmap! char *fallbackStr; ServiceProbe *fallbacks[MAXFALLBACKS+1]; - std::vector probableports; - std::vector probablesslports; - std::vector detectedServices; + std::unordered_set probableports; + std::unordered_set probablesslports; + std::unordered_set detectedServices; --- a/service_scan.cc +++ b/service_scan.cc @@ -1,6 +1,7 @@ #include "service_scan.h" +#include @@ -1215,7 +1215,7 @@ void ServiceProbe::setPortVector(std::vector *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 *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_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); }