47 lines
1.9 KiB
Diff
47 lines
1.9 KiB
Diff
# UNDF: UNDF-2026-000000896
|
|
--- a/src/network_inspectors/appid/service_plugins/service_discovery.cc
|
|
+++ b/src/network_inspectors/appid/service_plugins/service_discovery.cc
|
|
@@ -1,5 +1,6 @@
|
|
#include <algorithm>
|
|
#include <cstdlib>
|
|
+#include <unordered_set>
|
|
#include <vector>
|
|
|
|
// ... (includes)
|
|
@@ -262,13 +263,15 @@
|
|
ServiceMatch* match_list = nullptr;
|
|
patterns->find_all((const char*)pkt->data, pkt->dsize, &pattern_match, false,
|
|
(void*)&match_list);
|
|
|
|
std::vector<ServiceMatch*> smOrderedList;
|
|
for (ServiceMatch* sm = match_list; sm; sm = sm->next)
|
|
smOrderedList.emplace_back(sm);
|
|
|
|
if (!smOrderedList.empty() )
|
|
{
|
|
std::sort(smOrderedList.begin(), smOrderedList.end(), AppIdPatternPrecedence);
|
|
+ std::unordered_set<ServiceDetector*> seen(asd.service_candidates.begin(),
|
|
+ asd.service_candidates.end());
|
|
for ( auto& sm : smOrderedList )
|
|
{
|
|
- if ( std::find(asd.service_candidates.begin(), asd.service_candidates.end(),
|
|
- sm->service) == asd.service_candidates.end() )
|
|
+ if ( seen.insert(sm->service).second )
|
|
{
|
|
asd.service_candidates.emplace_back(sm->service);
|
|
}
|
|
@@ -348,9 +351,11 @@
|
|
{
|
|
asd.service_candidates = it1->second;
|
|
if (it2 != services.end() && it2 != it1)
|
|
{
|
|
+ std::unordered_set<ServiceDetector*> seen(asd.service_candidates.begin(),
|
|
+ asd.service_candidates.end());
|
|
for (ServiceDetector* candidate : it2->second)
|
|
{
|
|
- if (std::find(asd.service_candidates.begin(), asd.service_candidates.end(),
|
|
- candidate) == asd.service_candidates.end())
|
|
+ if (seen.insert(candidate).second)
|
|
asd.service_candidates.push_back(candidate);
|
|
}
|
|
}
|