diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java index 0af50391dbb..61f190a9c58 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java @@ -18,8 +18,10 @@ Licensed to the Apache Software Foundation (ASF) under one or more import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; +import java.io.FileNotFoundException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; @@ -61,6 +63,7 @@ public abstract class BaseTestPPTIterating { static { EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6416153805979648.ppt", Exception.class); EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6710128412590080.ppt", RuntimeException.class); + EXCLUDED.put("clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt", FileNotFoundException.class); } public static Stream files() { @@ -95,7 +98,11 @@ void tearDownBase() { } private static void findFile(List list, String dir) { - String[] files = new File(dir).list((arg0, arg1) -> arg1.toLowerCase(Locale.ROOT).endsWith(".ppt")); + File dirFile = new File(dir); + assertTrue(dirFile.exists(), "Directory does not exist: " + dirFile.getAbsolutePath()); + assertTrue(dirFile.isDirectory(), "Not a directory: " + dirFile.getAbsolutePath()); + + String[] files = dirFile.list((arg0, arg1) -> arg1.toLowerCase(Locale.ROOT).endsWith(".ppt")); assertNotNull(files, "Did not find any ppt files in directory " + dir); diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java index efdf770b267..90965f727d2 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java @@ -21,6 +21,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more import org.junit.jupiter.api.Test; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.Collections; import java.util.HashSet; @@ -56,6 +57,11 @@ void runOneFile(File pFile) throws Exception { throw e; } } + + // work around one file which works here but not in other tests + if (pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt")) { + throw new FileNotFoundException(); + } } @Override diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java b/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java index 4f229e9a180..3698c57b7ef 100644 --- a/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java +++ b/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java @@ -130,6 +130,9 @@ protected static Cipher initCipherForBlock(Cipher cipher, int block, } protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver) { + if (password == null) { + throw new IllegalArgumentException("Did not receive a password"); + } if (password.length() > 255) { password = password.substring(0, 255); } diff --git a/test-data/slideshow/clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt b/test-data/slideshow/clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt new file mode 100644 index 00000000000..5c9421f6280 Binary files /dev/null and b/test-data/slideshow/clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 3711182c299..d1b01472d31 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ