diff options
author | Nick Burch <nick@apache.org> | 2014-02-16 19:35:55 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2014-02-16 19:35:55 +0000 |
commit | 220b2638308534f360fa3011ebe1727224989d58 (patch) | |
tree | 59e05a7042fe4d7eebdd29c7ef6f6c9628b6388c /src | |
parent | 06f1a6a42eb825e6cfb18567306d8e89299b31fe (diff) | |
download | poi-220b2638308534f360fa3011ebe1727224989d58.tar.gz poi-220b2638308534f360fa3011ebe1727224989d58.zip |
Patch and test from Jon Iles from bug #56138 - HPSF code page strings can be zero length
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1568813 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/poi/hpsf/CodePageString.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/hpsf/CodePageString.java b/src/java/org/apache/poi/hpsf/CodePageString.java index eaaa11e51b..b94cb67c13 100644 --- a/src/java/org/apache/poi/hpsf/CodePageString.java +++ b/src/java/org/apache/poi/hpsf/CodePageString.java @@ -42,7 +42,7 @@ class CodePageString offset += LittleEndian.INT_SIZE; _value = LittleEndian.getByteArray( data, offset, size ); - if ( _value[size - 1] != 0 ) { + if ( size != 0 && _value[size - 1] != 0 ) { // TODO Some files, such as TestVisioWithCodepage.vsd, are currently // triggering this for values that don't look like codepages // See Bug #52258 for details diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java b/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java index 05c8d8b99f..ff9ba878a5 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java @@ -138,4 +138,27 @@ public final class TestHPSFBugs extends TestCase { assertEquals("", si.getAuthor()); assertEquals("Cour de Justice", dsi.getCompany()); } + + /** + * CodePage Strings can be zero length + */ + public void test56138() throws Exception { + DocumentInputStream dis; + POIFSFileSystem fs = + new POIFSFileSystem(_samples.openResourceAsStream("TestZeroLengthCodePage.mpp")); + + dis = fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME); + SummaryInformation si = (SummaryInformation)PropertySetFactory.create(dis); + + dis = fs.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + DocumentSummaryInformation dsi = (DocumentSummaryInformation)PropertySetFactory.create(dis); + + // Test + assertEquals("MSProject", si.getApplicationName()); + assertEquals("project1", si.getTitle()); + assertEquals("Jon Iles", si.getAuthor()); + + assertEquals("", dsi.getCompany()); + assertEquals(2, dsi.getSectionCount()); + } } |