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

opj_jp2_read_header: Check for error after parsing header. #1573

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

sebras
Copy link
Contributor

@sebras sebras commented Jan 16, 2025

Consider the case where the caller has not set the p_image pointer to NULL before calling opj_read_header().

If opj_j2k_read_header_procedure() fails while obtaining the rest of the marker segment when calling opj_stream_read_data() because the data stream is too short, then opj_j2k_read_header() will never have the chance to initialize p_image, leaving it uninitialized.

opj_jp2_read_header() will check the p_image value whether opj_j2k_read_header() suceeded or failed. This may be detected as an error in valgrind or ASAN.

The fix is to check whether opj_j2k_read_header() suceeded before using the output argument p_image.

Consider the case where the caller has not set the p_image
pointer to NULL before calling opj_read_header().

If opj_j2k_read_header_procedure() fails while obtaining the rest
of the marker segment when calling opj_stream_read_data() because
the data stream is too short, then opj_j2k_read_header() will
never have the chance to initialize p_image, leaving it
uninitialized.

opj_jp2_read_header() will check the p_image value whether
opj_j2k_read_header() suceeded or failed. This may be detected as
an error in valgrind or ASAN.

The fix is to check whether opj_j2k_read_header() suceeded before
using the output argument p_image.
@sebras
Copy link
Contributor Author

sebras commented Jan 16, 2025

In PR #1463 in commit 0f528e9, @rouault accidentally forgot to check the return value of opj_j2k_read_header() before processing its output arguments in opj_jp2_read_header(). This onliner PR fixes that minor buglet.

Thanks for maintaining openjpeg! :)

@rouault
Copy link
Collaborator

rouault commented Jan 16, 2025

thanks

@rouault rouault merged commit 44119c2 into uclouvain:master Jan 16, 2025
12 of 13 checks passed
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