Skip to content

Commit

Permalink
Allow extra FF bytes preceding JPEG markers
Browse files Browse the repository at this point in the history
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'."
  • Loading branch information
jeffrey-easyesi committed Dec 2, 2024
1 parent 4821449 commit b1bd862
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion openpdf/src/main/java/com/lowagie/text/Jpeg.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b1bd862

Please sign in to comment.