Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Potential buffer overflow errors #196

Merged
merged 1 commit into from
Sep 28, 2022

Conversation

af-a
Copy link
Contributor

@af-a af-a commented Sep 28, 2022

Description

We observed buffer overflow errors due to certain freesurfer commands that are executed in recon-surf (mri_label2vol and mris_anatomical_stats) when subject directory paths are too long.
This particulary occurs when a freesurfer version built for Ubuntu is run on a Centos machine, but may happen in other cases.

The following is an example of the error message (from recon-surf.log):

mri_label2vol --defects $SUBJECTS_DIR/$SUBJECT_ID/surf/lh.defect_labels \
    $SUBJECTS_DIR/$SUBJECT_ID/mri/orig.mgz 1000 0 \
    $SUBJECTS_DIR/$SUBJECT_ID/mri/lh.surface.defects.mgz
*** buffer overflow detected ***: terminated
Abort (core dumped)

This was the case when $SUBJECTS_DIR/$SUBJECT_ID was at least 192 characters long.

Solution

This PR adds a check in recon-surf.sh for the length of $SUBJECTS_DIR/$SUBJECT_ID, then raises an error and exits if it exceeds 185 characters.

@af-a af-a requested a review from m-reuter September 28, 2022 08:16
@m-reuter m-reuter merged commit 3a53188 into Deep-MI:feature/vinn Sep 28, 2022
@af-a af-a deleted the fix/buffer-overflow-errors branch September 28, 2022 08:43
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.

2 participants