mirror of https://github.com/apache/poi.git
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
This commit is contained in:
parent
482f4ca30d
commit
dbd8808432
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -130,6 +130,9 @@ public class CryptoAPIDecryptor extends Decryptor {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue