fix: Limit the buffer size of the simplified write API to 32 bits

In the simplified API, it is promised that libpng refuses an image
whose buffer size (as computed by `PNG_IMAGE_BUFFER_SIZE`) overflows
32 bits. Although this promise is kept in `png_image_finish_read`,
`png_image_write_main` computed the size from the minimum row stride
instead of the actual one, and without the size of a 16-bit component.
An image accepted by that check could make the writer read past the
end of its buffer.

This is a cherry-pick of commit 0b0876829d77db0827a8cc2c4326f63be22b2aa1
from branch 'libpng18'.

Reported-by: Madan301 <Madan301@users.noreply.github.com>
1 file changed