diff options
| author | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2014-12-14 22:20:06 +0100 |
|---|---|---|
| committer | ftrvxmtrx <ftrvxmtrx@gmail.com> | 2014-12-14 22:20:06 +0100 |
| commit | 0dc1929379f3cc628be7d6b50297c203b87f7a4d (patch) | |
| tree | 8851ee88a90f87818ccb1bf582b0b508aa0f1b5a | |
| parent | 67bed722f21cb216a0fcc3d3ebebf161b09439d4 (diff) | |
| download | plan9front-0dc1929379f3cc628be7d6b50297c203b87f7a4d.tar.xz | |
png: fail on invalid bpc
| -rw-r--r-- | sys/src/cmd/jpg/readpng.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/src/cmd/jpg/readpng.c b/sys/src/cmd/jpg/readpng.c index ef14e013f..a046b0cfa 100644 --- a/sys/src/cmd/jpg/readpng.c +++ b/sys/src/cmd/jpg/readpng.c @@ -420,30 +420,40 @@ readslave(Biobuf *b) 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; 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; 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; 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; 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; |
