Author: centic Date: Tue Jan 30 21:01:46 2024 New Revision: 1915480 URL: http://svn.apache.org/viewvc?rev=1915480&view=rev Log: Bug 66425: Avoid exceptions found via poi-fuzz
Prevent a few NullPointerException Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65450 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63907 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63727 Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java?rev=1915480&r1=1915479&r2=1915480&view=diff ============================================================================== --- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java (original) +++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java Tue Jan 30 21:01:46 2024 @@ -79,6 +79,9 @@ public class XSLFGraphicFrame extends XS } CTPoint2D off = xfrm.getOff(); + if (off == null) { + throw new IllegalArgumentException("Could not retrieve Off from the XML object"); + } double x = Units.toPoints(POIXMLUnits.parseLength(off.xgetX())); double y = Units.toPoints(POIXMLUnits.parseLength(off.xgetY())); CTPositiveSize2D ext = xfrm.getExt(); Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java?rev=1915480&r1=1915479&r2=1915480&view=diff ============================================================================== --- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java (original) +++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java Tue Jan 30 21:01:46 2024 @@ -88,7 +88,7 @@ public abstract class HWPFDocumentCore e * Size of the not encrypted part of the FIB */ protected static final int FIB_BASE_LEN = 68; - + /** * [MS-DOC] 2.2.6.2/3 Office Binary Document ... Encryption: * "... The block number MUST be set to zero at the beginning of the stream and @@ -283,6 +283,9 @@ public abstract class HWPFDocumentCore e EncryptionMode em = fibBase.isFObfuscated() ? EncryptionMode.xor : null; EncryptionInfo ei = new EncryptionInfo(leis, em); Decryptor dec = ei.getDecryptor(); + if (dec == null) { + throw new EncryptedDocumentException("Invalid encryption info, did not get a matching decryptor"); + } dec.setChunkSize(RC4_REKEYING_INTERVAL); try { String pass = Biff8EncryptionKey.getCurrentUserPassword(); Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java?rev=1915480&r1=1915479&r2=1915480&view=diff ============================================================================== --- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java (original) +++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java Tue Jan 30 21:01:46 2024 @@ -51,10 +51,16 @@ public class AgileEncryptionVerifier ext setCipherAlgorithm(keyData.getCipherAlgorithm()); setKeySize(keyData.getKeyBits()); - int blockSize = keyData.getBlockSize(); + Integer blockSize = keyData.getBlockSize(); + if (blockSize == null) { + throw new IllegalArgumentException("blockSize not set"); + } setBlockSize(blockSize); - int hashSize = keyData.getHashSize(); + Integer hashSize = keyData.getHashSize(); + if (hashSize == null) { + throw new IllegalArgumentException("hashSize not set"); + } HashAlgorithm ha = keyData.getHashAlgorithm(); setHashAlgorithm(ha); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
