From 697c3cfb34d0b6fe315fc4d303340275ab80c121 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 5 Aug 2012 20:01:04 +0200 Subject: Fix comparison of cmap table length against maximum value The cmap table length counts how many entries there are currently in the table. The table length was previously tested against USHRT_MAX which is 65535. However, the desired value to compare with was 65536 which would be the maximum number of entries allowed in a cmap table. All comparisons of the cmap table length are now using USHRT_MAX + 1. --- pdf/pdf_cmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c index cd0d6385..d6cb3103 100644 --- a/pdf/pdf_cmap.c +++ b/pdf/pdf_cmap.c @@ -184,7 +184,7 @@ pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n) static void add_table(fz_context *ctx, pdf_cmap *cmap, int value) { - if (cmap->tlen == USHRT_MAX) + if (cmap->tlen >= USHRT_MAX + 1) { fz_warn(ctx, "cmap table is full; ignoring additional entries"); return; @@ -233,7 +233,7 @@ pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *table, int int i; int high = low + len; int offset = cmap->tlen; - if (cmap->tlen + len >= USHRT_MAX) + if (cmap->tlen + len >= USHRT_MAX + 1) fz_warn(ctx, "cannot map range to table; table is full"); else { @@ -280,7 +280,7 @@ pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int low, int *values, int l return; } - if (cmap->tlen + len + 1 >= USHRT_MAX) + if (cmap->tlen + len + 1 >= USHRT_MAX + 1) fz_warn(ctx, "cannot map one to many; table is full"); else { @@ -314,7 +314,7 @@ pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap) qsort(cmap->ranges, cmap->rlen, sizeof(pdf_range), cmprange); - if (cmap->tlen == USHRT_MAX) + if (cmap->tlen >= USHRT_MAX + 1) { fz_warn(ctx, "cmap table is full; will not combine ranges"); return; -- cgit v1.2.3