Skip to content

Commit

Permalink
Fix bit shift overflow in bmp reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanBloomberg committed Dec 27, 2019
1 parent 73c4f12 commit 50c3c35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ PIXCMAP *cmap;
* to accommodate these newer formats. */
cmapbytes = offset - BMP_FHBYTES - ihbytes;
ncolors = cmapbytes / sizeof(RGBA_QUAD);
maxcolors = 1 << depth;
if (ncolors < 0 || ncolors == 1)
return (PIX *)ERROR_PTR("invalid: cmap size < 0 or 1", procName, NULL);
if (ncolors > 0 && depth > 8)
return (PIX *)ERROR_PTR("can't have cmap for d > 8", procName, NULL);
maxcolors = (depth <= 8) ? 1 << depth : 256;
if (ncolors > maxcolors) {
L_ERROR("cmap too large for depth: ncolors = %d > maxcolors = %d\n",
procName, ncolors, maxcolors);
Expand Down

0 comments on commit 50c3c35

Please sign in to comment.