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

Catch std::exception in iptcprint #2111

Merged
merged 1 commit into from
Feb 25, 2022
Merged

Conversation

kevinbackhouse
Copy link
Collaborator

The main function in the iptcprint sample program catches Exiv2::AnyError but not std::exception. The poc attached to #2050 is a bogus image file that triggers a std::overflow_error in this call to Safe::add():

enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), kerCorruptedMetadata);

In the exiv2 application, we catch those exceptions and print an error message. We just need to do the same in this sample application.

I also changed the error return code to 1, because -1 is non-standard.

@kevinbackhouse kevinbackhouse added this to the v1.00 milestone Feb 19, 2022
@kevinbackhouse kevinbackhouse linked an issue Feb 19, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Feb 19, 2022

Codecov Report

Merging #2111 (571c84f) into main (0b17cc3) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2111   +/-   ##
=======================================
  Coverage   63.80%   63.80%           
=======================================
  Files          96       96           
  Lines       19169    19169           
  Branches     9772     9772           
=======================================
  Hits        12230    12230           
  Misses       4658     4658           
  Partials     2281     2281           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b17cc3...571c84f. Read the comment docs.

@@ -68,5 +68,9 @@ try {
}
catch (Exiv2::AnyError& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use here EXIT_FAILURE? I like to use those exit values macros for making the code more readable:

https://en.cppreference.com/w/cpp/utility/program/EXIT_status

It is also fine for me if you want to merge this directly, and we can do a whole replacement of exit values in another PR

@piponazo piponazo merged commit b626f24 into Exiv2:main Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std::overflow_error when fuzzing iptcprint
2 participants