Skip to content

Fix remaining bugs in PNG reader#26748

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
vrabaud:png_leak
Jan 11, 2025
Merged

Fix remaining bugs in PNG reader#26748
asmorkalov merged 1 commit intoopencv:4.xfrom
vrabaud:png_leak

Conversation

@vrabaud
Copy link
Copy Markdown
Contributor

@vrabaud vrabaud commented Jan 10, 2025

  • read information at the very beginning (if reading chunk fails, reading the info might not be possible after)
  • do not try to allocate when the chunk is > PNG_USER_CHUNK_MALLOC_MAX

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • 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

@vrabaud vrabaud requested a review from asmorkalov January 10, 2025 13:59
@asmorkalov asmorkalov self-assigned this Jan 10, 2025
@asmorkalov asmorkalov added this to the 4.12.0 milestone Jan 10, 2025
@asmorkalov
Copy link
Copy Markdown
Contributor

The patch breaks a lot of tests with "libpng error: Not a PNG file" error:

[ RUN      ] Calib3d_StereoCalibrate_CPP.regression
libpng error: Not a PNG file
libpng error: Not a PNG file
/home/ci/opencv/modules/ts/src/ts.cpp:612: Failure
Failed

	failure reason: No test data
	test case #-1
	seed: 00000000000c5a5d
-----------------------------------
	LOG:
Can not load images /home/ci/opencv_extra/testdata/cv/stereo/case1/left01.png and /home/ci/opencv_extra/testdata/cv/stereo/case1/right01.png, testcase 1

-----------------------------------

[  FAILED  ] Calib3d_StereoCalibrate_CPP.regression (1 ms)

- free chunk before a potential longjmp
- do not try to allocate when the chunk is > PNG_USER_CHUNK_MALLOC_MAX
@vrabaud
Copy link
Copy Markdown
Contributor Author

vrabaud commented Jan 10, 2025

Sorry about the noise, this is the proper solution. @asmorkalov , the ASAN error is now fixed.

@asmorkalov asmorkalov merged commit 1e31f80 into opencv:4.x Jan 11, 2025
@asmorkalov asmorkalov mentioned this pull request Jan 15, 2025
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.

3 participants