Various arithmetic overflows occurs for images whose size does not fit in 4 G
Environment/Versions
- GIMP version: 2.10 (Also latest master I think)
- Package: Any
- Operating System: Any environment where int is 32 bit (and not 64 bit)
Description of the bug
May cause crashes in random places.
Reproduction
For example, use the file-raw-data plug-in and try to load a sufficiently large grayscale 8 bit per pixel image. The plug-in will crash because it overflow happened when it tried to calculate the number of bytes to allocate.
Expected result: Correctly computed sizes
Actual result: Overflow which results in crashes
Additional information
It looks like the codebase contains expressions like width * height
in various places. To solve the issue, I guess the best strategy is to centralize image_byte_size and image_area computations in inline functions.