Skip to content

Commit 4305087

Browse files
Allow extra FF bytes preceding JPEG markers (#1247)
From the JPEG specification, B.1.1.2: "Any marker may optionally be preceded by any number of fill bytes, which are bytes assigned code X'FF'."
1 parent b4a2e93 commit 4305087

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • openpdf/src/main/java/com/lowagie/text

openpdf/src/main/java/com/lowagie/text/Jpeg.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ private void processParameters() throws BadElementException, IOException {
241241
throw new IOException(MessageLocalization.getComposedMessage("premature.eof.while.reading.jpg"));
242242
}
243243
if (v == 0xFF) {
244-
int marker = is.read();
244+
int marker;
245+
do {
246+
marker = is.read();
247+
} while (marker == 0xFF); // Skip extra FF bytes, per JPEG spec B.1.1.2
245248
if (firstPass && marker == M_APP0) {
246249
firstPass = false;
247250
len = getShort(is);

0 commit comments

Comments
 (0)