Skip to content

Commit

Permalink
Bug 66425: Avoid a NullPointerException found via oss-fuzz
Browse files Browse the repository at this point in the history
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=62626

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912792 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
centic9 committed Oct 7, 2023
1 parent a428428 commit c331c5d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public abstract class BaseTestPPTIterating {
EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5962760801091584.ppt", RuntimeException.class);
EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5231088823566336.ppt", FileNotFoundException.class);
EXCLUDED.put("clusterfuzz-testcase-minimized-POIFuzzer-6411649193738240.ppt", FileNotFoundException.class);
EXCLUDED.put("clusterfuzz-testcase-minimized-POIHSLFFuzzer-4838893004128256.ppt", FileNotFoundException.class);
}

public static Stream<Arguments> files() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void runOneFile(File pFile) throws Exception {
if (pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5429732352851968.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-5681320547975168.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5231088823566336.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-6411649193738240.ppt")) {
pFile.getName().equals("clusterfuzz-testcase-minimized-POIFuzzer-6411649193738240.ppt") ||
pFile.getName().equals("clusterfuzz-testcase-minimized-POIHSLFFuzzer-4838893004128256.ppt")) {
throw new FileNotFoundException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ protected AgileEncryptionHeader(EncryptionDocument ed) {
keyData.getHashAlgorithm() + " @ " + hashSize + " bytes");
}

if (keyData.getSaltSize() == null) {
throw new EncryptedDocumentException("Invalid salt length: " + keyData.getSaltSize());
}

int saltLength = keyData.getSaltSize();
setKeySalt(keyData.getSaltValue());
if (getKeySalt().length != saltLength) {
throw new EncryptedDocumentException("Invalid salt length");
throw new EncryptedDocumentException("Invalid salt length: " + getKeySalt().length + " and " + saltLength);
}

DataIntegrity di = ed.getDataIntegrity();
Expand Down
Binary file not shown.
Binary file modified test-data/spreadsheet/stress.xls
Binary file not shown.

0 comments on commit c331c5d

Please sign in to comment.