From acecda5931657d155cba9f3c56e209693f02a086 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sat, 25 Jul 2015 13:54:26 +0200 Subject: Limit font encoding differences to unicode. Previously encoding differences were allowed outside the valid unicode codepoint range. Fixes one issue from bug 696012. --- source/pdf/pdf-encoding.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/pdf/pdf-encoding.c b/source/pdf/pdf-encoding.c index c634a9ee..e8e7532d 100644 --- a/source/pdf/pdf-encoding.c +++ b/source/pdf/pdf-encoding.c @@ -30,6 +30,7 @@ pdf_lookup_agl(char *name) char *p; int l = 0; int r = nelem(agl_name_list) - 1; + int code = 0; fz_strlcpy(buf, name, sizeof buf); @@ -51,14 +52,15 @@ pdf_lookup_agl(char *name) return agl_code_list[m]; } + if (strstr(buf, "uni") == buf) - return strtol(buf + 3, NULL, 16); + code = strtol(buf + 3, NULL, 16); else if (strstr(buf, "u") == buf) - return strtol(buf + 1, NULL, 16); + code = strtol(buf + 1, NULL, 16); else if (strstr(buf, "a") == buf && strlen(buf) >= 3) - return strtol(buf + 1, NULL, 10); + code = strtol(buf + 1, NULL, 10); - return 0; + return (code >= 0 && code <= 0x10ffff) ? code : 0; } static const char *empty_dup_list[] = { 0 }; -- cgit v1.2.3