diff options
author | Dominik Stadler <centic@apache.org> | 2023-09-11 18:25:01 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2023-09-11 18:25:01 +0000 |
commit | dbd88084324d2716517197e76d1feb4b224e1773 (patch) | |
tree | 626f9d8fd2fae5abc8d7f6a88f1055e2892df01a /poi-scratchpad | |
parent | 482f4ca30df736de2ac72a5bb81841138b5ed6e8 (diff) | |
download | poi-dbd88084324d2716517197e76d1feb4b224e1773.tar.gz poi-dbd88084324d2716517197e76d1feb4b224e1773.zip |
Bug 66425: Avoid a NullPointerException found via oss-fuzz
We try to avoid throwing NullPointerException, but it was possible
to trigger one here with a specially crafted input-file
Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62216
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912250 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad')
-rw-r--r-- | poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/BaseTestPPTIterating.java | 9 | ||||
-rw-r--r-- | poi-scratchpad/src/test/java/org/apache/poi/hslf/dev/TestPPTXMLDump.java | 6 |
2 files changed, 14 insertions, 1 deletions
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 0af50391db..61f190a9c5 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 @@ package org.apache.poi.hslf.dev; 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<Arguments> files() { @@ -95,7 +98,11 @@ public abstract class BaseTestPPTIterating { } private static void findFile(List<Arguments> 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 efdf770b26..90965f727d 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 @@ import org.apache.poi.hslf.HSLFTestDataSamples; 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 @@ public class TestPPTXMLDump extends BaseTestPPTIterating { 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 |