Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tyler92
Copy link
Contributor

@tyler92 tyler92 commented Jun 30, 2024

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

For invalid input data there is an exception here:

RGBE_ReadHeader(file, &m_width, &m_height, NULL);

which leads to missing fclose call. It's possible to wrap RGBE_ReadHeader with try-catch and call fclose in place, but I chose a more reliable way. Please let me know if another way is preferred for the fix.

The issue was found during the oss-fuzz testing.

==307898== FILE DESCRIPTORS: 1 open (0 std) at exit.
==307898== Open file descriptor 4: /tmp/__opencv_temp.R5cqbF
==307898==    at 0x4CD853B: open (open64.c:41)
==307898==    by 0x4C500B5: _IO_file_open (fileops.c:188)
==307898==    by 0x4C50411: _IO_file_fopen@@GLIBC_2.2.5 (fileops.c:280)
==307898==    by 0x4C436AD: __fopen_internal (iofopen.c:75)
==307898==    by 0x4C436AD: fopen@@GLIBC_2.2.5 (iofopen.c:86)
==307898==    by 0x662CFB: cv::HdrDecoder::readHeader() (modules/imgcodecs/src/grfmt_hdr.cpp:72)
==307898==    by 0x60315A: cv::imdecode_(cv::Mat const&, int, cv::Mat&) (modules/imgcodecs/src/loadsave.cpp:857)
==307898==    by 0x602366: cv::imdecode(cv::_InputArray const&, int) (modules/imgcodecs/src/loadsave.cpp:936)
==307898==    by 0x5F7BE2: LLVMFuzzerTestOneInput (imdecode_fuzzer.cc:51)

Test sample:
01ba0766ae85fb245abfb4e94ee828c98c772135

@asmorkalov asmorkalov merged commit 25609ef into opencv:4.x Jul 1, 2024
@asmorkalov asmorkalov added this to the 4.11.0 milestone Jul 1, 2024
@asmorkalov asmorkalov mentioned this pull request Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants