Skip to content

BUG: Fix an out-of-bounds indirect call in axio_show_mim_summary - #109

Open
hjmjohnson wants to merge 3 commits into
masterfrom
pr/fix-oob-indirect-call
Open

hjmjohnson wants to merge 3 commits into
masterfrom
pr/fix-oob-indirect-call

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #40, reverted from master on 2026-09-24 so it can be
reviewed before merging. Content is unchanged from the original.

Base: master. Independent: nothing has to land before it.

Commits
  • BUG: Fix an out-of-bounds indirect call in axio_show_mim_summary
  • ENH: Cover the MatrixIndicesMap dispatch in axio_show_mim_summary
  • BUG: Free the XML tree and image that cifti_tool parses

Ordering for all the re-submitted work is tracked in #84.

gdevenyi and others added 3 commits September 24, 2026 07:10
    mind = get_map_index(xt->xchild[kid]);
    if( kid >= 0 ) MIM_disp_funcs[mind](ofp, xt->xchild[kid], verb);

The guard tests kid, the loop counter, which is never negative, so it is
always true.  The index actually used is mind, and get_map_index()
returns -1 for any element name not in MIM_kids[].  A CIFTI file
containing an unrecognised element under MatrixIndicesMap therefore reads
a function pointer from before the start of MIM_disp_funcs and calls it.

Reported by the clang static analyzer as security.ArrayBound, "Out of
bound access to memory preceding 'MIM_disp_funcs'".

(cherry picked from commit b8d5246)
Drives cifti_tool with -eval_type show_summary over two XML fixtures.
The first holds a MatrixIndicesMap child whose name get_map_index()
does not resolve, and fails without the preceding commit: the sanitizer
legs report a global-buffer-overflow, an 8-byte read 8 bytes before
MIM_disp_funcs.

The second holds a BrainModel and asserts it is still displayed, so
that skipping the unresolved name cannot pass by skipping every name.

These are the first tests for the cifti library. The fixtures are small
enough to keep in tree, so neither needs the external testing data.

(cherry picked from commit 06cb5a6)
process() returned without releasing either the afni_xml_t it parsed or
the nifti_image the non-cext path fills in, so every run leaked the whole
tree. Both free routines already accept NULL, so neither path needs a
guard.

LeakSanitizer is on by default under AddressSanitizer on Linux but not on
Apple, so the leak ended the process with a non-zero status on the
sanitizer job alone. That also discarded the buffered standard output,
which is why the summary text went missing there rather than merely
being followed by a leak report.

(cherry picked from commit e96d1e9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants