ref: 674d8f53697d25624c7677e2eba01804a35fe669
parent: 80576e0a275d83a6bcd344265bdeeb85efb08176
author: Julian Smith <[email protected]>
date: Thu Nov 21 12:16:27 EST 2019
Coverity 350198: fixed jbig2_error() printf format / type mismatches. Unfortunately stdint_.h isn't available to jbig2dec code so we can't use PRIdSIZE. Have instead used %li with a cast to long. [This commit addresses all printf warnings from gcc -W -Wall; it probably fixes multiple similar coverity issues.]
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -664,14 +664,14 @@
/* SumatraPDF: prevent read access violation */
if (size < jbig2_huffman_offset(hs) || (size - jbig2_huffman_offset(hs) < (size_t) image->height * stride) || (size < jbig2_huffman_offset(hs))) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "not enough data for decoding uncompressed (%d/%d)", image->height * stride,
- size - jbig2_huffman_offset(hs));
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "not enough data for decoding uncompressed (%d/%li)", image->height * stride,
+ (long) (size - jbig2_huffman_offset(hs)));
goto cleanup;
}
BMSIZE = (size_t) image->height * stride;
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
- "reading %dx%d uncompressed bitmap for %d symbols (%d bytes)", image->width, image->height, NSYMSDECODED - HCFIRSTSYM, BMSIZE);
+ "reading %dx%d uncompressed bitmap for %d symbols (%li bytes)", image->width, image->height, NSYMSDECODED - HCFIRSTSYM, (long) BMSIZE);
for (j = 0; j < image->height; j++) {
memcpy(dst, src, stride);
@@ -683,12 +683,12 @@
/* SumatraPDF: prevent read access violation */
if (size < jbig2_huffman_offset(hs) || size < BMSIZE || size - jbig2_huffman_offset(hs) < BMSIZE) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "not enough data for decoding (%d/%d)", BMSIZE, size - jbig2_huffman_offset(hs));
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "not enough data for decoding (%li/%li)", (long) BMSIZE, (long) (size - jbig2_huffman_offset(hs)));
goto cleanup;
}
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
- "reading %dx%d collective bitmap for %d symbols (%d bytes)", image->width, image->height, NSYMSDECODED - HCFIRSTSYM, BMSIZE);
+ "reading %dx%d collective bitmap for %d symbols (%li bytes)", image->width, image->height, NSYMSDECODED - HCFIRSTSYM, (long) BMSIZE);
rparams.MMR = 1;
code = jbig2_decode_generic_mmr(ctx, segment, &rparams, data + jbig2_huffman_offset(hs), BMSIZE, image);