Add patch replacing linear TAILQ_FOREACH scan in mta_handle_envelope() with tree_get() on a per-relay task_by_msgid splay-tree index; assign UNDF-2026-000000201. Unit test confirms 100x op-count improvement at N=100 tasks/relay.
22 lines
1.1 KiB
Diff
22 lines
1.1 KiB
Diff
# UNDF: UNDF-2026-000000209
|
|
--- a/pwiz.py
|
|
+++ b/pwiz.py
|
|
@@ -72,7 +72,10 @@ def introspect(database, table_names=None, **kwargs):
|
|
|
|
def _print_table(table, seen, accum=None):
|
|
- accum = accum or []
|
|
+ # CWE-407 fix: replace list with set for O(1) membership checks.
|
|
+ # Original code used `if dest in accum` (O(N) scan) inside a loop
|
|
+ # over foreign keys, and passed `accum + [table]` (O(N) copy) on
|
|
+ # each recursive call — O(N²) total for schema graphs with deep FK chains.
|
|
+ accum = accum or set()
|
|
foreign_keys = database.foreign_keys[table]
|
|
for foreign_key in foreign_keys:
|
|
dest = foreign_key.dest_table
|
|
@@ -85,6 +88,6 @@ def introspect(database, table_names=None, **kwargs):
|
|
# not already processed the destination table, do so now.
|
|
if dest not in seen and dest not in accum:
|
|
seen.add(dest)
|
|
if dest != table:
|
|
- _print_table(dest, seen, accum + [table])
|
|
+ _print_table(dest, seen, accum | {table})
|