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
This commit is contained in:
parent
a1ed3f51e4
commit
75e57d9414
@ -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
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user