tiff: add thread-safe warning/error handlers, requires libtiff 4.5.0+ #4313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a compile-time test for libtiff
OpenOptions
feature, when present sets the use of new, re-entrant error and warning handlers.Defining these (and having them
return 1
) prevents the default behaviour of libtiff to call global, not thread-safe handlers shared between all users.The handlers also support user data, so
tiffload
can now start to respect thefail_on
option. Homebrew currently provides libtiff 4.7.0 so we can test for this on macOS.I also investigated the various new memory limit safety features of
OpenOptions
discussed in #3892 but these only cover libtiff allocations e.g. parsing headers, and exclude allocations in its dependencies. Newer versions of libtiff already introduce more sanity checks around these anyway so the example from https://issues.oss-fuzz.com/issues/42531230 no longer fails.This PR targets the 8.16 branch as it fixes a long-standing potential thread-safety issue with libtiff. I guess this might be considered a breaking change only if someone is currently settingfail_on=warning
but expecting it not to 10000 .