This is an automated email from the ASF dual-hosted git repository. centic pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/poi.git
commit bc02ef070348ff2c94f85776d344c83cdcd80ec7 Author: Dominik Stadler <[email protected]> AuthorDate: Sat Feb 14 20:04:58 2026 +0100 Avoid NPE with malformed wmf headers --- .../java/org/apache/poi/hwmf/record/HwmfMisc.java | 14 ++++++++++++-- ...sterfuzz-testcase-minimized-6701721724125184.wmf | Bin 0 -> 87 bytes test-data/spreadsheet/stress.xls | Bin 79872 -> 79872 bytes 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfMisc.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfMisc.java index da669354df..8130f7d7e3 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfMisc.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfMisc.java @@ -511,8 +511,18 @@ public class HwmfMisc { @Override public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { - style = HwmfBrushStyle.valueOf(leis.readUShort()); - colorUsage = ColorUsage.valueOf(leis.readUShort()); + int brushStyle = leis.readUShort(); + style = HwmfBrushStyle.valueOf(brushStyle); + if (style == null) { + throw new IllegalArgumentException("Could not read brush-style " + brushStyle); + } + + int colorUsageEnum = leis.readUShort(); + colorUsage = ColorUsage.valueOf(colorUsageEnum); + if (colorUsage == null) { + throw new IllegalArgumentException("Could not read color-usage " + colorUsage); + } + int size = 2*LittleEndianConsts.SHORT_SIZE; switch (style) { case BS_SOLID: diff --git a/test-data/slideshow/clusterfuzz-testcase-minimized-6701721724125184.wmf b/test-data/slideshow/clusterfuzz-testcase-minimized-6701721724125184.wmf new file mode 100644 index 0000000000..abda269ddb Binary files /dev/null and b/test-data/slideshow/clusterfuzz-testcase-minimized-6701721724125184.wmf differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 099e41e45e..cd4be7f1dc 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
