From be1cb0c59cde0140caca43a93832866a993ddbf3 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 26 May 2015 13:46:20 +0000 Subject: [PATCH] Fix NPOIFS to handle dodgy excel-95 file from bug #46904 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1681756 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java | 2 +- src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java index 4ad5c0a5b1..bb5b3a50ed 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java @@ -436,7 +436,7 @@ public class NPOIFSFileSystem extends BlockStore List sbats = new ArrayList(); _mini_store = new NPOIFSMiniStore(this, _property_table.getRoot(), sbats, _header); nextAt = _header.getSBATStart(); - for(int i=0; i<_header.getSBATCount(); i++) { + for(int i=0; i<_header.getSBATCount() && nextAt != POIFSConstants.END_OF_CHAIN; i++) { loopDetector.claim(nextAt); ByteBuffer fatData = getBlockAt(nextAt); sfat = BATBlock.createBATBlock(bigBlockSize, fatData); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 36f397c01e..df470f26cf 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1578,8 +1578,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { "The supplied spreadsheet seems to be Excel" )); } - // TODO Fix this to work with NPOIFS as well -/* try { NPOIFSFileSystem fs = new NPOIFSFileSystem( HSSFITestDataProvider.instance.openWorkbookStream("46904.xls")); @@ -1590,7 +1588,6 @@ public final class TestBugs extends BaseTestBugzillaIssues { "The supplied spreadsheet seems to be Excel" )); } -*/ } /** -- 2.39.5