ref: 0dc1929379f3cc628be7d6b50297c203b87f7a4d
parent: 67bed722f21cb216a0fcc3d3ebebf161b09439d4
author: ftrvxmtrx <[email protected]>
date: Sun Dec 14 17:20:06 EST 2014
png: fail on invalid bpc
--- a/sys/src/cmd/jpg/readpng.c
+++ b/sys/src/cmd/jpg/readpng.c
@@ -420,6 +420,8 @@
nout = 0;
switch(colorfmt){
case 0: /* grey */
+ if(bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8 && bpc != 16)
+ sysfatal("invalid greyscale bpc %d", bpc);
image->nchans = 1;
image->chandesc = CY;
nout = 1;
@@ -426,6 +428,8 @@
nchan = 1;
break;
case 2: /* rgb */
+ if(bpc != 8 && bpc != 16)
+ sysfatal("invalid rgb bpc %d", bpc);
image->nchans = 1;
image->chandesc = CRGB24;
nout = 3;
@@ -432,6 +436,8 @@
nchan = 3;
break;
case 3: /* indexed rgb with PLTE */
+ if(bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8)
+ sysfatal("invalid indexed rgb bpc %d", bpc);
image->nchans = 1;
image->chandesc = CRGB24;
nout = 3;
@@ -438,6 +444,8 @@
nchan = 1;
break;
case 4: /* grey+alpha */
+ if(bpc != 8 && bpc != 16)
+ sysfatal("invalid grey+alpha bpc %d", bpc);
image->nchans = 1;
image->chandesc = CYA16;
nout = 2;
@@ -444,6 +452,8 @@
nchan = 2;
break;
case 6: /* rgb+alpha */
+ if(bpc != 8 && bpc != 16)
+ sysfatal("invalid rgb+alpha bpc %d", bpc);
image->nchans = 1;
image->chandesc = CRGBA32;
nout = 4;