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

Crash when calling NrrdImageIO::Write() with an overly long file name #4623

Open
TrudbertSchwoerer opened this issue Apr 29, 2024 · 5 comments
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Comments

@TrudbertSchwoerer
Copy link

Description

  • Calling NrrdImageIO::Write(const void* buffer) with a buffersize larger than 1025 byte.
  • This will finally be passed to _biffMsgAddVL(biffMsg *msg, const char *errfmt, va_list args) as argument in args.
  • vsprintf writes the argument together with the format string into the local buffer errstr, which has a fixed size of 1025 byte.
  • This overwrites the stack and leads to a crash.

Steps to Reproduce

This crash was observed in our MITK based application and was reproducible there.

Expected behavior

Application should not crash.

Actual behavior

Application crashes.

See the debugger stack trace below:
debug

Reproducibility

100% reproducible

Versions

ITK 5.2 as part of MITK 2023.04

Environment

Ran as part of a MITK based application.

@TrudbertSchwoerer TrudbertSchwoerer added the type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances label Apr 29, 2024
Copy link

Thank you for contributing an issue! 🙏

Welcome to the ITK community! 🤗👋☀️

We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜
Also, please check existing open issues and consider discussion on the ITK Discourse. 📖

This is an automatic message. Allow for time for the ITK community to be able to read the issue and comment on it.

@N-Dekker
Copy link
Contributor

@seanm Could it be that you already fixed this issue, by your efforts to replace sprintf usage with snprintf? (This issue was reported with ITK 5.2.)

For example:

@seanm
Copy link
Contributor

seanm commented May 1, 2024

Could be!

@TrudbertSchwoerer do you repro with master?

@TrudbertSchwoerer
Copy link
Author

TrudbertSchwoerer commented May 2, 2024 via email

@seanm
Copy link
Contributor

seanm commented May 7, 2024

In fact no, I did not fix this, because it's not in ITK proper but in 3rd party code in /Modules/ThirdParty/NrrdIO/src/NrrdIO/biffbiff.c

This should be fixed in their upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances
Projects
None yet
Development

No branches or pull requests

3 participants