summaryrefslogtreecommitdiffstats
path: root/poi/src/test
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2023-01-06 23:50:54 +0000
committerPJ Fanning <fanningpj@apache.org>2023-01-06 23:50:54 +0000
commit968dabd462725b5ee13aa43cedcee4719e98ecc5 (patch)
treee6170071fa9ec0aa9137a62aa415c15bcae92949 /poi/src/test
parentc8c06d1ec0bf9619af1a455513cf1dfb8aa6a0e4 (diff)
downloadpoi-968dabd462725b5ee13aa43cedcee4719e98ecc5.tar.gz
poi-968dabd462725b5ee13aa43cedcee4719e98ecc5.zip
[bug-65543] HSSF: fix issue with incomplete SSTs. Thanks to Simon Carter.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906434 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/test')
-rw-r--r--poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java b/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java
index 20057c42ac..c627bbfc55 100644
--- a/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java
+++ b/poi/src/test/java/org/apache/poi/hssf/record/TestSSTDeserializer.java
@@ -120,4 +120,23 @@ final class TestSSTDeserializer {
assertEquals( "At a dinner party orAt At At ", strings.get( 0 ) + "" );
}
+
+ /**
+ * Ensure that invalid SST records with an incorrect number of strings specified, does not consume non-continuation records.
+ */
+ @Test
+ void test65543() throws IOException {
+ final byte[] sstRecord = readSampleHexData("notenoughstrings.txt", "sst-record", SSTRecord.sid);
+ byte[] nonContinuationRecord = readSampleHexData("notenoughstrings.txt", "non-continuation-record", ExtSSTRecord.sid);
+ RecordInputStream in = TestcaseRecordInputStream.create(concat(sstRecord, nonContinuationRecord));
+
+ IntMapper<UnicodeString> strings = new IntMapper<>();
+ SSTDeserializer deserializer = new SSTDeserializer(strings);
+
+ // The record data in notenoughstrings.txt only contains 1 string, deliberately pass in a larger number.
+ deserializer.manufactureStrings(2, in);
+
+ assertEquals("At a dinner party or", strings.get(0) + "");
+ assertEquals("", strings.get(1) + "");
+ }
}