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 23369586da33ed3e3bbc8ace5c472803a60f7536 Author: Dominik Stadler <[email protected]> AuthorDate: Sat Feb 21 14:11:13 2026 +0100 Avoid assertion when handling slightly corrupted emf-file Also remove methods which are identical to the ones in the super-class Fixes https://issues.oss-fuzz.com/issues/486039135 --- .../org/apache/poi/hemf/record/emf/HemfFill.java | 23 +++++++++------------ ...mized-POIFileHandlerFuzzer-6466833057382400.emf | Bin 0 -> 41 bytes test-data/spreadsheet/stress.xls | Bin 80896 -> 80896 bytes 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java index 4930959fde..477b6ecb00 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emf/HemfFill.java @@ -35,6 +35,7 @@ import java.util.Map; import java.util.function.Supplier; import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; +import org.apache.logging.log4j.Logger; import org.apache.poi.hemf.draw.HemfDrawProperties; import org.apache.poi.hemf.draw.HemfGraphics; import org.apache.poi.hwmf.draw.HwmfGraphics; @@ -45,6 +46,7 @@ import org.apache.poi.hwmf.record.HwmfFill; import org.apache.poi.hwmf.record.HwmfFill.ColorUsage; import org.apache.poi.hwmf.record.HwmfRegionMode; import org.apache.poi.hwmf.record.HwmfTernaryRasterOp; +import org.apache.poi.logging.PoiLogManager; import org.apache.poi.util.GenericRecordJsonWriter; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.IOUtils; @@ -52,6 +54,8 @@ import org.apache.poi.util.LittleEndianConsts; import org.apache.poi.util.LittleEndianInputStream; public final class HemfFill { + private static final Logger LOG = PoiLogManager.getLogger(HemfFill.class); + private HemfFill() {} /** @@ -194,11 +198,6 @@ public final class HemfFill { super.draw(ctx); } - @Override - public String toString() { - return GenericRecordJsonWriter.marshal(this); - } - public Rectangle2D getBounds() { return bounds; } @@ -321,14 +320,8 @@ public final class HemfFill { public HemfRecordType getEmfRecordType() { return HemfRecordType.bitBlt; } - - @Override - protected boolean srcEqualsDstDimension() { - return false; - } } - /** The EMR_FRAMERGN record draws a border around the specified region using the specified brush. */ public static class EmfFrameRgn extends HwmfDraw.WmfFrameRegion implements HemfRecord { private final Rectangle2D bounds = new Rectangle2D.Double(); @@ -611,9 +604,13 @@ public final class HemfFill { size += readBounds2(leis, destRect); blendOperation = leis.readByte(); - assert (blendOperation == 0); + if (blendOperation != 0) { + LOG.atWarn().log("Unexpected blend-operation in emf file: {}", blendOperation); + } blendFlags = leis.readByte(); - assert (blendOperation == 0); + if (blendFlags != 0) { + LOG.atWarn().log("Unexpected blend-flags in emf file: {}", blendFlags); + } srcConstantAlpha = leis.readUByte(); alphaFormat = leis.readByte(); diff --git a/test-data/slideshow/clusterfuzz-testcase-minimized-POIFileHandlerFuzzer-6466833057382400.emf b/test-data/slideshow/clusterfuzz-testcase-minimized-POIFileHandlerFuzzer-6466833057382400.emf new file mode 100644 index 0000000000..9e018a8074 Binary files /dev/null and b/test-data/slideshow/clusterfuzz-testcase-minimized-POIFileHandlerFuzzer-6466833057382400.emf differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index db5b3318d1..ed7f422722 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]
