You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2022/09/10 11:34:53 UTC
svn commit: r1903963 - /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
Author: tilman
Date: Sat Sep 10 11:34:53 2022
New Revision: 1903963
URL: http://svn.apache.org/viewvc?rev=1903963&view=rev
Log:
PDFBOX-5507: avoid IndexOutOfBoundsException
Modified:
pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java?rev=1903963&r1=1903962&r2=1903963&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java Sat Sep 10 11:34:53 2022
@@ -274,6 +274,10 @@ public class CMapParser
checkExpectedOperator((Operator) nextToken, "endcodespacerange", "codespacerange");
break;
}
+ if (!(nextToken instanceof byte[]))
+ {
+ throw new IOException("start range missing");
+ }
byte[] startRange = (byte[]) nextToken;
byte[] endRange = (byte[]) parseNextToken(cmapStream);
try
@@ -297,6 +301,10 @@ public class CMapParser
checkExpectedOperator((Operator) nextToken, "endbfchar", "bfchar");
break;
}
+ if (!(nextToken instanceof byte[]))
+ {
+ throw new IOException("input code missing");
+ }
byte[] inputCode = (byte[]) nextToken;
nextToken = parseNextToken(cmapStream);
if (nextToken instanceof byte[])
@@ -327,6 +335,10 @@ public class CMapParser
checkExpectedOperator((Operator) nextToken, "endcidrange", "cidrange");
break;
}
+ if (!(nextToken instanceof byte[]))
+ {
+ throw new IOException("start range missing");
+ }
byte[] startCode = (byte[]) nextToken;
int start = createIntFromBytes(startCode);
byte[] endCode = (byte[]) parseNextToken(cmapStream);
@@ -368,6 +380,10 @@ public class CMapParser
checkExpectedOperator((Operator) nextToken, "endcidchar", "cidchar");
break;
}
+ if (!(nextToken instanceof byte[]))
+ {
+ throw new IOException("start code missing");
+ }
byte[] inputCode = (byte[]) nextToken;
int mappedCode = (Integer) parseNextToken(cmapStream);
int mappedCID = createIntFromBytes(inputCode);
@@ -380,26 +396,26 @@ public class CMapParser
for (int j = 0; j < cosCount.intValue(); j++)
{
Object nextToken = parseNextToken(cmapStream);
- if (nextToken == null)
- {
- throw new IOException("start code missing");
- }
if (nextToken instanceof Operator)
{
checkExpectedOperator((Operator) nextToken, "endbfrange", "bfrange");
break;
}
- byte[] startCode = (byte[]) nextToken;
- nextToken = parseNextToken(cmapStream);
- if (nextToken == null)
+ if (!(nextToken instanceof byte[]))
{
- throw new IOException("end code missing");
+ throw new IOException("start code missing");
}
+ byte[] startCode = (byte[]) nextToken;
+ nextToken = parseNextToken(cmapStream);
if (nextToken instanceof Operator)
{
checkExpectedOperator((Operator) nextToken, "endbfrange", "bfrange");
break;
}
+ if (!(nextToken instanceof byte[]))
+ {
+ throw new IOException("end code missing");
+ }
byte[] endCode = (byte[]) nextToken;
int start = CMap.toInt(startCode, startCode.length);
int end = CMap.toInt(endCode, endCode.length);