Avoid overflow in image cell size calculation

This commit is contained in:
Michael Grant
2026-08-08 10:33:54 +01:00
parent 37b71800b5
commit 48b6641d97

View File

@@ -633,8 +633,8 @@ image_size_in_cells(u_int width, u_int height, u_int xpixel, u_int ypixel,
xpixel = 8;
if (ypixel == 0)
ypixel = 16;
*sx = ((uint64_t)width + xpixel - 1) / xpixel;
*sy = ((uint64_t)height + ypixel - 1) / ypixel;
*sx = width / xpixel + (width % xpixel != 0);
*sy = height / ypixel + (height % ypixel != 0);
}
/* Decode a base64 payload with a size limit. */