Do not resize images greater than 32767 pixels in either dimension

Internally, the resizing code uses the rockbox dim structure, which uses signed shorts.

Change-Id: Ic8850e8563a9d8c0cb3cf8269e2576be9e42b45b
This commit is contained in:
Michael Giacomelli 2020-12-09 01:05:48 -05:00
parent 56f4ec9668
commit 64cc9aad73

9
apps/recorder/jpeg_load.c Normal file → Executable file
View file

@ -2050,6 +2050,15 @@ int clip_jpeg_fd(int fd,
if (!(status & DHT)) /* if no Huffman table present: */
default_huff_tbl(p_jpeg); /* use default */
fix_headers(p_jpeg); /* derive Huffman and other lookup-tables */
/*the dim array in rockbox is limited to 2^15-1 pixels, so we cannot resize
images larger than this without overflowing */
if(p_jpeg->x_size > 32767 || p_jpeg->y_size > 32767)
{
JDEBUGF("Aborting resize of image > 32767 pixels\n");
return -1;
}
src_dim.width = p_jpeg->x_size;
src_dim.height = p_jpeg->y_size;
if (format & FORMAT_RESIZE)