aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi
diff options
context:
space:
mode:
authorTim Allison <tallison@apache.org>2017-07-14 20:47:40 +0000
committerTim Allison <tallison@apache.org>2017-07-14 20:47:40 +0000
commitd320b2ea4a0ad32e8d49b8ce3f6ac1583ea48a5a (patch)
tree07ad6e558e5a337858e5f47ba6be0e4609899d91 /src/testcases/org/apache/poi
parent5c674c92d382ec019273a9e1d09dad44f6eb99ca (diff)
downloadpoi-d320b2ea4a0ad32e8d49b8ce3f6ac1583ea48a5a.tar.gz
poi-d320b2ea4a0ad32e8d49b8ce3f6ac1583ea48a5a.zip
bug 61300 -- prevent really long (infinite?) loop on corrupt file
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801989 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi')
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestReSave.java12
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java15
7 files changed, 32 insertions, 5 deletions
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java
index ffcb676d5c..c739364c42 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java
@@ -24,6 +24,7 @@ import java.io.PrintStream;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.util.RecordFormatException;
import org.junit.BeforeClass;
public class TestBiffDrawingToXml extends BaseXLSIteratingTest {
@@ -45,6 +46,7 @@ public class TestBiffDrawingToXml extends BaseXLSIteratingTest {
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
+ EXCLUDED.put("61300.xls", RecordFormatException.class);
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java
index 5a36de4940..414ae7f2fe 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java
@@ -28,6 +28,7 @@ import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.util.LocaleUtil;
+import org.apache.poi.util.RecordFormatException;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -53,6 +54,7 @@ public class TestBiffViewer extends BaseXLSIteratingTest {
// EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("50833.xls", IllegalArgumentException.class); // "Name is too long" when setting username
EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"
+ EXCLUDED.put("61300.xls", RecordFormatException.class);
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java
index e07b9ff8e9..0ba83ae55f 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java
@@ -24,6 +24,7 @@ import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LocaleUtil;
+import org.apache.poi.util.RecordFormatException;
import org.junit.BeforeClass;
public class TestEFBiffViewer extends BaseXLSIteratingTest {
@@ -46,6 +47,7 @@ public class TestEFBiffViewer extends BaseXLSIteratingTest {
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"
+ EXCLUDED.put("61300.xls", RecordFormatException.class);
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java
index 3e575f22ba..a272fc9314 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java
@@ -25,6 +25,7 @@ import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LocaleUtil;
+import org.apache.poi.util.RecordFormatException;
import org.junit.BeforeClass;
public class TestFormulaViewer extends BaseXLSIteratingTest {
@@ -46,6 +47,7 @@ public class TestFormulaViewer extends BaseXLSIteratingTest {
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
+ EXCLUDED.put("61300.xls", RecordFormatException.class);
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
index b1ae03aa9a..09d560de7e 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java
@@ -16,20 +16,21 @@
==================================================================== */
package org.apache.poi.hssf.dev;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.PrintStream;
+
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LocaleUtil;
+import org.apache.poi.util.RecordFormatException;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-import java.io.File;
-import java.io.PrintStream;
-
-import static org.junit.Assert.assertTrue;
-
public class TestReSave extends BaseXLSIteratingTest {
@BeforeClass
public static void setup() {
@@ -50,6 +51,7 @@ public class TestReSave extends BaseXLSIteratingTest {
EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"
+ EXCLUDED.put("61300.xls", RecordFormatException.class);
}
@Override
diff --git a/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java b/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java
index a74846d463..cf0907ea6e 100644
--- a/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java
+++ b/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java
@@ -22,6 +22,7 @@ import java.io.PrintStream;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.util.LocaleUtil;
+import org.apache.poi.util.RecordFormatException;
import org.junit.BeforeClass;
public class TestRecordLister extends BaseXLSIteratingTest {
@@ -37,6 +38,7 @@ public class TestRecordLister extends BaseXLSIteratingTest {
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
+ EXCLUDED.put("61300.xls", RecordFormatException.class);
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
index adc07bd952..f249fadf40 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -45,6 +45,8 @@ import java.util.Locale;
import java.util.TimeZone;
import org.apache.poi.EncryptedDocumentException;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.OldExcelFormatException;
@@ -63,6 +65,8 @@ import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
import org.apache.poi.hssf.record.aggregates.RecordAggregate;
import org.apache.poi.hssf.record.common.UnicodeString;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
+import org.apache.poi.poifs.filesystem.DocumentEntry;
+import org.apache.poi.poifs.filesystem.DocumentInputStream;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.OPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@@ -3139,4 +3143,15 @@ public final class TestBugs extends BaseTestBugzillaIssues {
wb.close();
}
+ @Test(expected = RuntimeException.class)
+ public void test61300() throws Exception {
+ NPOIFSFileSystem npoifs = new NPOIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls"));
+
+ DocumentEntry entry =
+ (DocumentEntry) npoifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
+ PropertySet properties =
+ new PropertySet(new DocumentInputStream(entry));
+
+ }
+
}