#define SETPIXEL(op, v) { \
switch (npixels++ & 3) { \
- case 0: op[0] = (v) << 6; break; \
+ case 0: op[0] = (u_char) ((v) << 6); break; \
case 1: op[0] |= (v) << 4; break; \
case 2: op[0] |= (v) << 2; break; \
case 3: *op++ |= (v); break; \
*/
off = (bp[0] * 256) + bp[1];
n = (bp[2] * 256) + bp[3];
- if (cc < 4+n)
+ if (cc < 4+n || off+n > scanline)
goto bad;
_TIFFmemcpy(row+off, bp+4, n);
bp += 4+n;
n &= 0x3f;
while (n-- > 0)
SETPIXEL(op, grey);
- if (npixels >= imagewidth)
+ if (npixels >= (int) imagewidth)
break;
if (cc == 0)
goto bad;