java-topology/whitepaper/outreach/pcsx2-0002.md
russell@unturf.com 652608142a feat: close outreach doc gap — 276 docs (batches 11-16)
All projects with patches now have outreach docs. 276 new docs covering
CWE-407, CWE-312, CWE-362 across C, C++, Java, Python, Go, Rust, C#,
PHP, Ruby, JavaScript, Dart, Erlang, R, and more.

Outreach gap: 276 -> 0.
2026-04-15 13:57:42 -04:00

1.8 KiB
Raw Permalink Blame History

PCSX2 — CWE-407 Disclosure Brief (pcsx2-0002)

2026-04-13 · Patch available — awaiting upstream merge

Finding

O(N²) codec deduplication in GSCapture where std::find_if scans the codec result list for every codec returned by av_codec_iterate(), checking for duplicate names.

The Defect

pcsx2-0002 (PATCHED — LOW): pcsx2/GS/GSCapture.cpp:1498

// Inside av_codec_iterate loop:
if (std::find_if(ret.begin(), ret.end(),
    [codec](const auto& it) { return it.first == codec->name; }) != ret.end())
    continue;

Each new codec checks the entire result list for name duplicates. With C codecs, total cost is O(C²).

Complexity Proof

At C=200 codecs:

  • Defective: ~20,000 string comparisons
  • Fixed: 200 hash insertions
  • ~100× op reduction.

Impact

PCSX2 enumerates available codecs when opening the capture/recording settings dialog. While the codec count is typically bounded, the quadratic pattern fires on every dialog open and scales with ffmpeg/libavcodec version (newer versions expose more codecs).

The Fix

Add an unordered_set<string> seen_codecs for O(1) dedup:

std::unordered_set<std::string> seen_codecs;
// ...
if (!seen_codecs.insert(codec->name).second)
    continue;

Patch

Fix available: defects/pcsx2-0002/patch/pcsx2-0002-gscapture-codec-dedup-set.patch

Single-file patch in GSCapture.cpp.

What We Ask

A patch is ready for review.

  1. Confirm receipt and assign a GitHub issue reference (PCSX2/pcsx2).
  2. Assess severity — low (bounded codec count), but straightforward fix.
  3. Coordinate a disclosure date — we target 90 days from first contact.
  4. We will credit the PCSX2 team in the public disclosure. Preferred acknowledgment format welcome.

Contact: see cover email. This brief is confidential until coordinated disclosure.