Browse Source

Add in a (disabled) test for bug #43670 (not yet fixed)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@589417 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_0_2_BETA1
Nick Burch 16 years ago
parent
commit
067739ba0d

+ 6
- 0
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java View File

@@ -107,6 +107,12 @@ public class ChunkFactory {
// Create the header
ChunkHeader header =
ChunkHeader.createChunkHeader(version, data, offset);
// Sanity check
if(header.length < 0) {
throw new IllegalArgumentException("Found a chunk with a negative length, which isn't allowed");
}
// How far up to look
int endOfDataPos = offset + header.getLength() + header.getSizeInBytes();
// Check we have enough data, and tweak the header size

+ 1
- 0
src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeader.java View File

@@ -45,6 +45,7 @@ public abstract class ChunkHeader {
ch.length = (int)LittleEndian.getUInt(data, offset + 12);
ch.unknown2 = LittleEndian.getShort(data, offset + 16);
ch.unknown3 = (short)LittleEndian.getUnsignedByte(data, offset + 18);
return ch;
} else if(documentVersion == 5) {
throw new RuntimeException("TODO");

+ 17
- 3
src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java View File

@@ -25,11 +25,13 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import junit.framework.TestCase;

public class TestHDGFCore extends TestCase {
POIFSFileSystem fs;
private POIFSFileSystem fs;
private String dirname;
private String filename;
protected void setUp() throws Exception {
String dirname = System.getProperty("HDGF.testdata.path");
String filename = dirname + "/Test_Visio-Some_Random_Text.vsd";
dirname = System.getProperty("HDGF.testdata.path");
filename = dirname + "/Test_Visio-Some_Random_Text.vsd";
fs = new POIFSFileSystem(new FileInputStream(filename));
}
@@ -59,4 +61,16 @@ public class TestHDGFCore extends TestCase {
assertNotNull(ps8.getPointedToStreams());
assertEquals(8, ps8.getPointedToStreams().length);
}
/**
* Tests that we can open a problematic file, that initially
* appears to have a negative chunk length
*/
public void DISABLEDtestNegativeChunkLength() throws Exception {
filename = dirname + "/NegativeChunkLength.vsd";
fs = new POIFSFileSystem(new FileInputStream(filename));
HDGFDiagram hdgf = new HDGFDiagram(fs);
assertNotNull(hdgf);
}
}

BIN
src/scratchpad/testcases/org/apache/poi/hdgf/data/NegativeChunkLength.vsd View File


Loading…
Cancel
Save