diff --git a/pdf.c b/pdf.c index 2e5e321b3527918833c5cbba4e4769b85703a4de..2504e7863a4e7bf2c232b98cd7d93988bd581dac 100644 --- a/pdf.c +++ b/pdf.c @@ -1248,11 +1248,11 @@ p_xrefdata__m(HAllocator *mm__, const Dict *dict) return p_fail; if (i < 3) { /* we can't take >64 bits and want to use size_t */ - if (w > 8 || w > sizeof(size_t)) + if (w > 8 || (uint64_t)w > sizeof(size_t)) return p_fail; W[i] = (size_t)w; } else { - if (w > SIZE_MAX - Wskip) + if ((uint64_t)w > SIZE_MAX - Wskip) return p_fail; /* overflow */ Wskip += w; } @@ -1330,7 +1330,7 @@ p_xrefdata__m(HAllocator *mm__, const Dict *dict) if (base->token_type != TT_SINT || base->sint < 0 || n->token_type != TT_SINT || n->sint < 0 || - n->sint > SIZE_MAX) + (uint64_t)n->sint > SIZE_MAX) return p_fail; p_subs[i] = p_xrefsub__m(mm__, base->sint, n->sint, @@ -1467,7 +1467,7 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *nxrefs) * one xref section at the beginning of the file that is * allowed to point forward. */ - if (tok->sint >= offset) + if ((uint64_t)tok->sint >= offset) nfwd++; if (nfwd > 1) { fprintf(stderr, "%s: /Prev pointer of xref section at "