- if (occ < n + 1)
- {
- TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "PackBitsDecode: discarding %d bytes "
- "to avoid buffer overrun",
- n - occ + 1);
- n = occ - 1;
- }
- _TIFFmemcpy(op, bp, ++n);
+ if (occ < (tmsize_t)(n + 1))
+ {
+ TIFFWarningExt(tif->tif_clientdata, module,
+ "Discarding %lu bytes to avoid buffer overrun",
+ (unsigned long) ((tmsize_t)n - occ + 1));
+ n = (long)occ - 1;
+ }
+ if (cc < (tmsize_t) (n+1))
+ {
+ TIFFWarningExt(tif->tif_clientdata, module,
+ "Terminating PackBitsDecode due to lack of data.");
+ break;
+ }
+ _TIFFmemcpy(op, bp, ++n);