dataSize = totalSize;\r
break;\r
}\r
- \r
+\r
+ if ((long)dataSize + (long)ofs > (long)data.length) { //cast to avoid overflow\r
+ throw new Ole10NativeException("Invalid Ole10Native: declared data length > available data");\r
+ }\r
dataBuffer = new byte[dataSize];\r
System.arraycopy(data, ofs, dataBuffer, 0, dataSize);\r
ofs += dataSize;\r
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.File;
}
@Test
- @Ignore("BUG 60256")
public void testOleNativeOOM() throws IOException, Ole10NativeException {
POIFSFileSystem fs = new POIFSFileSystem(dataSamples.openResourceAsStream("60256.bin"));
- Ole10Native ole = Ole10Native.createFromEmbeddedOleObject(fs);
+ try {
+ Ole10Native.createFromEmbeddedOleObject(fs);
+ fail("Should have thrown exception because OLENative lacks a length parameter");
+ } catch (Ole10NativeException e) {
+ assertTrue(e.getMessage().indexOf("declared data length") > -1);
+ }
}
}