opensmtpd-0001: mta_handle_envelope TAILQ_FOREACH O(N²) task lookup — patch + unit test
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.
This commit is contained in:
parent
2573ec8802
commit
c9e86c450c
7 changed files with 485 additions and 364 deletions
22
defects/peewee/patch/peewee-0001-print-table-accum-set.patch
Normal file
22
defects/peewee/patch/peewee-0001-print-table-accum-set.patch
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# 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})
|
||||
Loading…
Add table
Add a link
Reference in a new issue