java-topology/defects/speed-dreams-0002/patch/speed-dreams-0002.patch
russell@unturf.com 294ab0a792 nfs-utils: 2 CWE-407 defects, MOAD 0002-0005 CLEAN
nfs-utils-0001: client_lookup() non-FQDN branch O(N) linked list
  scan per call in support/export/client.c:289. With N unique
  wildcard/netgroup/subnet clients, export_read totals O(N^2).
  Fix: hash table for hostname lookup. 119x at N=4000.

nfs-utils-0002: get_exportlist() in utils/mountd/mountd.c,
  lookup_or_create_elist_entry O(E) path scan + insert_group
  O(G) dedup scan, both per export = O(E^2) total. Fix: hash
  tables for path lookup and group dedup. 73x at N=4000.

MOAD-0002 (intertangle): clientlist/exportlist globals are standard
  single-threaded daemon design, single execution context. CLEAN.
MOAD-0003 (leaked context): no __thread or pthread_getspecific. CLEAN.
MOAD-0004 (logged secret): gssd logs keytab paths and principal
  names (not credentials). No key material logged. CLEAN.
MOAD-0005 (thundering herd): caches protected by ple_lock mutex
  in gssd, single-threaded event loop in mountd. CLEAN.
2026-03-31 13:19:01 -04:00

20 lines
1.1 KiB
Diff

--- a/src/modules/userinterface/legacymenu/racescreens/driverselect.cpp
+++ b/src/modules/userinterface/legacymenu/racescreens/driverselect.cpp
@@ -1164,13 +1164,17 @@
// d) Keep only drivers accepted by the race and not already among competitors
// (but don't reject humans with the wrong car category : they must be able to change it).
+ // Build a set for O(1) competitor lookup instead of O(N) linear scan.
+ std::set<GfDriver*> setCompetitors(vecCompetitors.begin(), vecCompetitors.end());
+
std::vector<GfDriver*>::const_iterator itCandidate;
for (itCandidate = vecCandidates.begin(); itCandidate != vecCandidates.end(); ++itCandidate)
{
- if (std::find(vecCompetitors.begin(), vecCompetitors.end(), *itCandidate)
- == vecCompetitors.end()
+ if (setCompetitors.find(*itCandidate) == setCompetitors.end()
&& MenuData->pRace->acceptsDriverType((*itCandidate)->getType())
&& (strCarModel == AnyCarModel
|| (*itCandidate)->getCar()->getId() == strCarModel)
&& ((*itCandidate)->isHuman()
|| MenuData->pRace->acceptsCarCategory((*itCandidate)->getCar()->getCategoryId())))