You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/07/14 15:23:56 UTC

[Bug 59858] New: NullPointerException thrown by VBAMacroReader

https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

            Bug ID: 59858
           Summary: NullPointerException thrown by VBAMacroReader
           Product: POI
           Version: 3.15-dev
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POIFS
          Assignee: dev@poi.apache.org
          Reporter: brooke@usinternet.com

I am getting a NullPointerException when trying to extract the macro VBA from a
particular Excel file.

I am using org.apache.poi.poifs.macros.VBAMacroReader

The following code consistently reproduces the NullPointerException:

File file = new File("npe_example.xls");
VBAMacroReader reader = new VBAMacroReader(file);
Map<String, String> macros = reader.readMacros();

I have attached the file which causes the error.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #1 from brooke@usinternet.com ---
Created attachment 34038
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34038&action=edit
Example xls that causes readMacros() to throw a NullPointerException

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #6 from Javen O'Neal <on...@apache.org> ---
Added unit test that reproduces the problem in r1752776.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #8 from Tim Allison <ta...@mitre.org> ---
This file has two _VBA_PROJECT_CUR directories; both have Sheet1, Sheet2 and
Sheet3 and thisWorkbook.  The _VBA_PROJECT_CUR under MDB00082648 has only empty
(zero-byte) Sheet1, etc.; whereas the _VBA_PROJECT_CUR under root has
meaningful content.

We are keying only off the name of the stream (e.g. "Sheet2") in our module
map.  This means that we're overwriting (or skipping) the other "Sheet2".

For now, I propose checking if the module.buf is null.  If it is, then we
expect an offset and we can read go about reading it.

Longer term, we might consider a way to prevent overwriting/skipping of streams
with the same module name?

Perhaps this is what is meant by "TODO Refactor this to fetch dir then do the
rest"?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

brooke@usinternet.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brooke@usinternet.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #2 from brooke@usinternet.com ---
Created attachment 34039
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34039&action=edit
The results of running org.apache.poi.poifs.dev.POIFSDump.main on the problem
document.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #5 from Javen O'Neal <on...@apache.org> ---
A module offset was not set before trying to read the stream.
https://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java?revision=1738674&view=markup#l258

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #7 from Javen O'Neal <on...@apache.org> ---
Replaced NullPointerException with IOException with an error message of the
name of the module that the VBAMacroReader failed to read in r1752778.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #4 from brooke@usinternet.com ---
Here is the stack trace:

Exception in thread "main" java.lang.NullPointerException
    at
org.apache.poi.poifs.macros.VBAMacroReader.readMacros(VBAMacroReader.java:258)
    at
org.apache.poi.poifs.macros.VBAMacroReader.findMacros(VBAMacroReader.java:148)
    at
org.apache.poi.poifs.macros.VBAMacroReader.findMacros(VBAMacroReader.java:153)
    at
org.apache.poi.poifs.macros.VBAMacroReader.findMacros(VBAMacroReader.java:153)
    at
org.apache.poi.poifs.macros.VBAMacroReader.findMacros(VBAMacroReader.java:153)
    at
org.apache.poi.poifs.macros.VBAMacroReader.readMacros(VBAMacroReader.java:115)
    at poitester.POITester.main(POITester.java:39)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

--- Comment #3 from Javen O'Neal <on...@apache.org> ---
Could you provide a stack trace?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59858] NullPointerException thrown by VBAMacroReader

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59858

Tim Allison <ta...@mitre.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #9 from Tim Allison <ta...@mitre.org> ---
r1765479

For now, I've added a check to see if we've already read the module with that
name.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org