P2: abort-rearm on a ship that is not being rearmed reads past the object array
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Read sexp_abort_rearm in sexp.cpp and compare its support ship lookup with the existing ai_abort_rearm_request helper in aicode.cpp. The issue describes three possible fixes; check the helper’s behavior and relevant rearm tests before choosing an approach. Done means abort-rearm safely does nothing when no support ship is servicing the named ship.
Written by the indexing model from the issue text.
Description
Problem
The abort-rearm sexp crashes or corrupts memory when the ship it names is not currently being rearmed. Mission designers may reasonably use it to cancel a rearm "just in case", but if no support ship is servicing that ship, the sexp hands the repair code an object at index -1 and the repair code reads through it.
In sexp_abort_rearm (sexp.cpp), the support ship is looked up from the ship's AI info without checking that one is set, so &Objects[-1] is passed to ai_do_objects_repairing_stuff, which then walks that object's docking list.
Steps to reproduce
- FSO master (tested on 12a36dc1a with an ASan debug build;
sexp.cpp,aicode.cppandobjectdock.cppare unchanged on current master 76219fd1e), Linux, MediaVPs 5.0.2. - Any mission with a ship that is not being rearmed (I used a GTF Myrmidon given a play-dead order).
- Run
( abort-rearm "<that ship>" )from an event.
Expected vs. actual behavior
Expected: nothing happens, since there is no rearm to abort.
Actual: AddressSanitizer reports a global-buffer-overflow read in dock_find_instance (objectdock.cpp:1047), called from ai_do_objects_repairing_stuff (aicode.cpp:11378) and sexp_abort_rearm (sexp.cpp:15342). The address read is the slot just before the global object array. Without the sanitizer the result depends on whatever memory sits there.
Proposed fixes
- Skip ships with no support ship. In
sexp_abort_rearm, continue to the next ship whensupport_ship_objnumis negative. One line, matches what the sexp promises. - Guard inside the repair function. Have
ai_do_objects_repairing_stuffignore an abort when the repair object is invalid, which also protects any other caller. - Route through the existing abort helper. Call
ai_abort_rearm_request, which already handles the "nobody is servicing me" case, instead of calling the repair code directly.
- Dominant language
- C++
- Stars
- 488
- Forks
- 184
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 40
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scp-fs2open/fs2open.github.com
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
scp-fs2open/fs2open.github.com#7918 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
scp-fs2open/fs2open.github.com#7916 ·
Maintainers usually reply within 1 day
-
P2: A timed rotation maneuver does nothing on a ship that had an earlier timed lateral maneuverPossibly taken @vovosta claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scp-fs2open/fs2open.github.com#7914 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
scp-fs2open/fs2open.github.com#7901 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
scp-fs2open/fs2open.github.com#7899 ·
Maintainers usually reply within 1 day
All issues in scp-fs2open/fs2open.github.com
Similar issues
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days
-
MinGW build faillureOpen
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
facebookresearch/faiss#5775 · 1 comment ·
Maintainers usually reply within 2 days
-
Eval bug: minimax-m3: build_moe_ffn() drops the per-expert NVFP4 scale → garbled output (M3.1 Flash)Openbug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
secondlife/viewer#6507 ·
Maintainers usually reply within 1 day
-
clang:frontend code-cleanup HLSL
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
llvm/llvm-project#235100 · 1 comment ·
Maintainers usually reply within 1 day