From b1bd8625aa6efc3543347a94bba6f79817210ba0 Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Mon, 2 Dec 2024 15:46:15 -0800 Subject: [PATCH] Allow extra FF bytes preceding JPEG markers 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'." --- openpdf/src/main/java/com/lowagie/text/Jpeg.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openpdf/src/main/java/com/lowagie/text/Jpeg.java b/openpdf/src/main/java/com/lowagie/text/Jpeg.java index d8111977f..3ae6692f7 100644 --- a/openpdf/src/main/java/com/lowagie/text/Jpeg.java +++ b/openpdf/src/main/java/com/lowagie/text/Jpeg.java @@ -241,7 +241,10 @@ private void processParameters() throws BadElementException, IOException { throw new IOException(MessageLocalization.getComposedMessage("premature.eof.while.reading.jpg")); } if (v == 0xFF) { - int marker = is.read(); + int marker; + do { + marker = is.read(); + } while (marker == 0xFF); // Skip extra FF bytes, per JPEG spec B.1.1.2 if (firstPass && marker == M_APP0) { firstPass = false; len = getShort(is);