From 6234c859d4c93d95f97ad6f385ce950778931b96 Mon Sep 17 00:00:00 2001 From: Tim Allison Date: Tue, 18 Oct 2016 12:55:34 +0000 Subject: [PATCH] BUG 60158 -- AIOOBE in VBAMacroReader git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765433 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/poifs/macros/VBAMacroReader.java | 3 +++ .../poi/util/RLEDecompressingInputStream.java | 2 +- .../poi/poifs/macros/TestVBAMacroReader.java | 15 ++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java index 66ebab97dc..90727c24a8 100644 --- a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java +++ b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java @@ -265,6 +265,9 @@ public class VBAMacroReader implements Closeable { private static final int MODULETYPE_PROCEDURAL = 0x0021; private static final int MODULETYPE_DOCUMENT_CLASS_OR_DESIGNER = 0x0022; private static final int PROJECTLCID = 0x0002; + private static final int MODULE_NAME = 0x0019; + private static final int MODULE_NAME_UNICODE = 0x0047; + private static final int MODULE_DOC_STRING = 0x001c; /** * Reads VBA Project modules from a VBA Project directory located at diff --git a/src/java/org/apache/poi/util/RLEDecompressingInputStream.java b/src/java/org/apache/poi/util/RLEDecompressingInputStream.java index f319965454..471fdab2cd 100644 --- a/src/java/org/apache/poi/util/RLEDecompressingInputStream.java +++ b/src/java/org/apache/poi/util/RLEDecompressingInputStream.java @@ -91,7 +91,7 @@ public class RLEDecompressingInputStream extends InputStream { return -1; } } - return buf[pos++]; + return buf[pos++]& 0xFF; } @Override diff --git a/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java b/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java index 614b4effaf..0e634b5c58 100644 --- a/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java +++ b/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java @@ -280,16 +280,13 @@ public class TestVBAMacroReader { } } } - - // This test is written as expected-to-fail and should be rewritten - // as expected-to-pass when the bug is fixed. + @Test public void bug60158() throws IOException { - try { - fromFile(POIDataSamples.getDocumentInstance(), "60158.docm"); - testPassesNow(60158); - } catch (ArrayIndexOutOfBoundsException e) { - skipTest(e); - } + File f = POIDataSamples.getDocumentInstance().getFile("60158.docm"); + VBAMacroReader r = new VBAMacroReader(f); + Map macros = r.readMacros(); + assertNotNull(macros.get("NewMacros")); + assertContains(macros.get("NewMacros"), "' dirty"); } } -- 2.39.5