-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P3
-
Affects Version/s: 8u481, 11.0.30-oracle, 17.0.18, 17.0.18-oracle, 21.0.10, 21.0.10-oracle, 25.0.2, 26, 27
-
Component/s: client-libs
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
|---|---|---|---|---|---|---|
| JDK-8375707 | 26.0.1 | Damon Nguyen | P3 | Resolved | Fixed | b03 |
| JDK-8375327 | 26 | Damon Nguyen | P3 | Resolved | Fixed | b31 |
| JDK-8375430 | 25.0.3-oracle | Dmitry Markov | P3 | Resolved | Fixed | b02 |
| JDK-8376333 | 25.0.3 | Goetz Lindenmaier | P3 | Resolved | Fixed | master |
| JDK-8375473 | 21.0.11-oracle | Dmitry Markov | P3 | Resolved | Fixed | b02 |
| JDK-8376468 | 21.0.11 | Goetz Lindenmaier | P3 | Resolved | Fixed | master |
| JDK-8375539 | 17.0.19-oracle | Dmitry Markov | P3 | Resolved | Fixed | b02 |
| JDK-8375619 | 11.0.31-oracle | Dmitry Markov | P3 | Resolved | Fixed | b02 |
| JDK-8375962 | 8u491 | Dmitry Markov | P3 | Resolved | Fixed | b02 |
Main problem: multi-line bitmap arrays
=============================
All the bitmap bytes are parsed only if the line contains "[]":
https://github.com/openjdk/jdk/blob/jdk-26+11/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java#L154
So the following data lines are being ignored, which for valid.xbm, means the whole image data is ignored:
https://github.com/openjdk/jdk/blob/jdk-26+11/test/jdk/java/awt/image/XBMDecoder/valid.xbm#L6
https://github.com/openjdk/jdk/blob/jdk-26+11/test/jdk/java/awt/image/XBMDecoder/valid_hex.xbm#L4
Unfortunately, the test case isn't checking the parsed image data, so it isn't catching the issue. I suggest at least checking the image data isn't full of zeros (this would detect the problem with valid.xbm), see XBMDecoderTest.java changes in https://bugs.openjdk.org/secure/attachment/118016/JDK-8373727-test-suggestions.patch.
Please note that matching "[]" might also be too restrictive, as whitespace should probably be allowed between the square brackets. But this is a minor issue, and perhaps acceptable for a minimalist parser.
Additional problem: regexes
=====================
I've also spotted some regex mistakes where the intention was to define a group (should be enclosed between parenthesis), but the code defines a character set (is enclosed between square brackets):
• matchRegex = "(0[xX])?[0-9a-fA-F]+[\\s+]?[,|};]"
• Very likely intended to be matchRegex = "(0[xX])?[0-9a-fA-F]+(\\s+)?(,|\\};)"
• And can be simplified as matchRegex = "(0[xX])?[0-9a-fA-F]+\\s*(,|\\};)"
• replaceRegex = "(0[xX])|,|[\\s+]|[};]"
• Very likely intended to be replaceRegex = "(0[xX])|,|(\\s+)|(\\};)"
• And can be simplified as replaceRegex = "0[xX]|,|\\s+|\\};"
As a consequence, invalid files containing a plus sign are not rejected by the parser. I suggest adding a test case for this, see invalid_plus.xbm in https://bugs.openjdk.org/secure/attachment/118016/JDK-8373727-test-suggestions.patch.
New findings: order of width and height definitions
======================================
As we can see in the ImageMagick parser, they don't tolerate any order for the width and height #defines, but they check the suffixes. However the new
https://github.com/ImageMagick/ImageMagick/blob/7.1.1-47/coders/xbm.c#L233-L255
https://github.com/openjdk/jdk/blob/jdk-26+11/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java#L113-L119
The old parser was far from readable and robust, but it loosely distinguished width from height, by matching the last one/two letter(s) in widt<h>/heig<ht>:
https://github.com/openjdk/jdk/blob/jdk-26+10/src/java.desktop/share/classes/sun/awt/image/XbmImageDecoder.java#L109-L112
- backported by
-
JDK-8375327 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8375430 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8375473 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8375539 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8375619 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8375707 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8375962 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8376333 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
-
JDK-8376468 New XBM images parser regression: only the first line of the bitmap array is parsed
-
- Resolved
-
- caused by
-
JDK-8361748 Enforce limits on the size of an XBM image
-
- Resolved
-
- causes
-
JDK-8374209 [17u,21u] Backout JDK-8361748 due to JDK-8373727
-
- Resolved
-
- relates to
-
JDK-8376270 [21u, 17u] Redo JDK-8361748: Enforce limits on the size of an XBM image
-
- Resolved
-
- links to
-
Commit(jdk26)
openjdk/jdk/d011d7c7
-
Commit(master)
openjdk/jdk21u-dev/4a081ec6
-
Commit(master)
openjdk/jdk25u-dev/85385b75
-
Commit(master)
openjdk/jdk/7f707ba8
-
Review(jdk26)
openjdk/jdk/29204
-
Review(master)
openjdk/jdk21u-dev/2575
-
Review(master)
openjdk/jdk25u-dev/177
-
Review(master)
openjdk/jdk/29120
-
Review(pr/4244)
openjdk/jdk17u-dev/4245