Skip to content

[InterventionalRadiologyController] Fix various potential bugs - #236

Open
fredroy wants to merge 6 commits into
sofa-framework:masterfrom
fredroy:fix_various_bugs
Open

[InterventionalRadiologyController] Fix various potential bugs#236
fredroy wants to merge 6 commits into
sofa-framework:masterfrom
fredroy:fix_various_bugs

Conversation

@fredroy

@fredroy fredroy commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Based on

(Claude)

Fix Severity Issue Test
1 OOB STEP 3: the prev_xId search could end == m_nodeCurvAbs.size(), then indexed m_nodeCurvAbs[prev_xId] / m_idInstrumentCurvAbsTable[prev_xId] out of bounds. Clamp to the last node. covered by deploy_*
2 OOB A negative controlledInstrument passed the upper-bound-only checks in onBeginAnimationStep() and applyAction() and was used as a negative index. Reject id < 0. action_negativeControlledInstrument_isRejected, deploy_negativeControlledInstrument_fallsBackToZero`
3 OOB computeInstrumentsCurvAbs() accessed xP_noticeable_I[size()-1] unconditionally; an empty sampling vector underflows. Skip such an instrument. defensive
4 Correctness interventionalRadiologyCollisionControls() used 0 as the "nothing to remove" sentinel in segRemove, dropping a collision point at index 0. Use -1. collision-pipeline only
5 Correctness totalLengthIsChanging() monotonic clamp started at i > 1, skipping node 1, which could dip below the origin and feed unsorted abscissa into the STEP 3 interpolation. Start at i > 0. covered by deploy_*
6 OOB STEP 5 rigid-segment loop could compute firstSimulatedNode + i == numberOfNodes (one past the last dof) and pass it to addConstraint. Bound the loop. defensive

@fredroy fredroy added pr: fix pr: clean pr: status to review To notify reviewers to review this pull-request labels Jul 16, 2026
@fredroy
fredroy force-pushed the fix_various_bugs branch from dbdcfc0 to 3aec1ed Compare July 20, 2026 04:42
@fredroy
fredroy force-pushed the fix_various_bugs branch from 3aec1ed to 9f344fd Compare July 30, 2026 01:32
In applyInterventionalRadiologyController() STEP 3, the search for the
previous node could leave prev_xId == m_nodeCurvAbs.size() (the "Case 1"
path), leading to out-of-bounds reads of m_nodeCurvAbs[prev_xId] and
m_idInstrumentCurvAbsTable[prev_xId]. Clamp prev_xId to the last node.
The monotonicity clamp on modifiedNodeCurvAbs started at i > 1, skipping
node 1, which could then dip below node 0 (the origin) and feed unsorted
curv abscissa into the STEP 3 interpolation. Start the clamp at i > 0.
The loop fixing rigid-segment border nodes could compute
firstSimulatedNode + i == numberOfNodes (one past the last dof) and pass it
to FixedProjectiveConstraint::addConstraint. Stop the loop before the index
leaves the valid dof range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: clean pr: fix pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant