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

suppress clang undefined behavior sanitizer in ImfAttribute<T>::copyValuesFrom() #779

Conversation

cary-ilm
Copy link
Member

Addresses https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23996

If an input file contains an invalid value for DeepImageState, clang will generate an Invalid-enum-value warning. The proper behavior is to carry the invalid value, so it will be preserved on file write. This could potentially happen with "legal" files if the DeepImageState enum were ever extended in the future, in which case old versions of the library should read the new files.

Suppressing the warning in this one case is preferable to disabling all undefined behavior by the sanitizer, because other instances of undefined behavior may be legitimate bugs.

Signed-off-by: Cary Phillips cary@ilm.com

Signed-off-by: Cary Phillips <cary@ilm.com>
Signed-off-by: Cary Phillips <cary@ilm.com>
@meshula
Copy link
Contributor

meshula commented Jul 14, 2020

same comment as per #780

@cary-ilm
Copy link
Member Author

Revisiting this after some consideration. @peterhillman, is the proper solution to avoid assigning the invalid DeepImageState enum value as you did in #785, or allow the invalid value and shut the sanitizer up, as this change does? I don't believe that invalid DeepImageState values are caught by sanityCheck(). Is that intentional or an oversight?

@peterhillman
Copy link
Contributor

@cary-ilm Looking specifically at enums which could be "invalid" in a file: Compression, LineOrder, PixelType and TileDescription are all enums which influence the data in the file. Unknown values make the file unreadable and sanityCheck should catch them. It makes sense to catch them in readValueFrom too, before they are cast to enum, to avoid undefined behavior.
DeepImageState and EnvMap have no effect on reading data from the file, and could potentially be extended in the future. It would be nice to allow future values through, which means sanityCheck should not catch them, though that does require them to be validated when they are used.

@cary-ilm cary-ilm changed the title suppress clang undefined behavior sanitizer in ImfAttribute<T>::e copyValuesFrom() suppress clang undefined behavior sanitizer in ImfAttribute<T>::copyValuesFrom() Jul 21, 2020
@cary-ilm
Copy link
Member Author

Closing this in favor of #794, a better solution.

@cary-ilm cary-ilm closed this Jul 22, 2020
@cary-ilm cary-ilm deleted the nosanitize-deepimagestate branch May 18, 2021 03:21
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.

4 participants