Skip to content

Commit

Permalink
Bug 66425: Avoid Exceptions found via oss-fuzz
Browse files Browse the repository at this point in the history
We try to avoid throwing NullPointerExceptions or endless allocations,
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=62706

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912794 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
centic9 committed Oct 7, 2023
1 parent 6fae5bb commit 50b4da4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import com.microsoft.schemas.office.visio.x2012.main.PageType;
import com.microsoft.schemas.office.visio.x2012.main.PagesDocument;
import com.microsoft.schemas.office.visio.x2012.main.PagesType;
import com.microsoft.schemas.office.visio.x2012.main.RelType;

import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
Expand Down Expand Up @@ -68,7 +70,12 @@ protected void onDocumentRead() {
// this iteration is ordered by page number
for (PageType pageSettings: _pagesObject.getPageArray()) {

String relId = pageSettings.getRel().getId();
RelType rel = pageSettings.getRel();
if (rel == null) {
throw new IllegalStateException("Could not read relation for page settings");
}

String relId = rel.getId();

POIXMLDocumentPart pageContentsPart = getRelationById(relId);
if (pageContentsPart == null)
Expand Down
Binary file not shown.
Binary file modified test-data/spreadsheet/stress.xls
Binary file not shown.

0 comments on commit 50b4da4

Please sign in to comment.