Skip to content

A14-11: quartet_concordance.cpp: n0/n1 indexed by unvalidated state codes, no bounds guard against negative states #107

Description

@ms609

src/quartet_concordance.cpp:20-27,43-51max_state tracks only the maximum non-NA state seen (to decide whether to grow n0/n1), but nothing rejects a negative state value before it's used to index n0[state]/n1[state] at :43,47,50. Currently safe only because the R caller (characters <- PhyDatToMatrix(dataset)levelToInt[match(...)], always >= 1 or NA) never passes a negative code — the C++ function itself has no defence if that invariant changes.

Verified via direct code read (orchestrator, since the haiku batch omitted this item on its first pass).

Fix: reject or clamp negative state values at function entry, don't rely solely on the R-side contract.

Filed by /red-team area 14 (opus finder, 2026-08-05).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:14Red-team focus area 14in-progressBeing fixed; claiming comment names the branchred-teamFiled by the /red-team rotationsev:lowP3: robustness / polish

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions