Bug 66425: Avoid Exceptions found via oss-fuzz

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
This commit is contained in:
Dominik Stadler 2023-10-07 22:12:30 +00:00
parent 6fae5bbc18
commit 50b4da40b8
3 changed files with 8 additions and 1 deletions

View File

@ -25,6 +25,8 @@ import java.util.List;
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;
@ -68,7 +70,12 @@ public class XDGFPages extends XDGFXMLDocumentPart {
// 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)

Binary file not shown.