summaryrefslogtreecommitdiff
path: root/poppler
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2006-01-18 18:54:12 +0000
committerAlbert Astals Cid <aacid@kde.org>2006-01-18 18:54:12 +0000
commitd66f3647ff1c38318d4cd056cb4d4c7a32eb6603 (patch)
treedab89ded554621c8044c8f2c7a9c1566ae01622e /poppler
parentd78b670339c8f92a32ab5f0a574d0e21690806f8 (diff)
poppler/CharCodeToUnicode.cc: Fix check for length that was not
having into account that there could be \n or \r in tokens an that those do not have to be took into account. Fixes http://bugs.kde.org/show_bug.cgi?id=120310
Diffstat (limited to 'poppler')
-rw-r--r--poppler/CharCodeToUnicode.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index c2121785..40abf0aa 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -243,8 +243,18 @@ void CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data,
}
if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
tok2[0] == '<' && tok2[n2 - 1] == '>')) {
- error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
- continue;
+
+ // check there was no line jump inside the token and so the length is
+ // longer than it should be
+ int countAux = 0;
+ for (int k = 0; k < n1; k++)
+ if (tok1[k] != '\n' && tok1[k] != '\r') countAux++;
+
+ if (!(countAux == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
+ tok2[0] == '<' && tok2[n2 - 1] == '>')) {
+ error(-1, "Illegal entry in bfchar block in ToUnicode CMap");
+ continue;
+ }
}
tok1[n1 - 1] = tok2[n2 - 1] = '\0';
if (sscanf(tok1 + 1, "%x", &code1) != 1) {
@@ -268,8 +278,21 @@ void CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data,
}
if (!(n1 == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
n2 == 2 + nDigits && tok2[0] == '<' && tok2[n2 - 1] == '>')) {
- error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
- continue;
+ // check there was no line jump inside the token and so the length is
+ // longer than it should be
+ int countAux = 0;
+ for (int k = 0; k < n1; k++)
+ if (tok1[k] != '\n' && tok1[k] != '\r') countAux++;
+
+ int countAux2 = 0;
+ for (int k = 0; k < n1; k++)
+ if (tok2[k] != '\n' && tok2[k] != '\r') countAux++;
+
+ if (!(countAux == 2 + nDigits && tok1[0] == '<' && tok1[n1 - 1] == '>' &&
+ countAux2 == 2 + nDigits && tok2[0] == '<' && tok2[n2 - 1] == '>')) {
+ error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
+ continue;
+ }
}
tok1[n1 - 1] = tok2[n2 - 1] = '\0';
if (sscanf(tok1 + 1, "%x", &code1) != 1 ||