Bug 68163 - VBAMacroReader throws NullPointerException for .doc file
Summary: VBAMacroReader throws NullPointerException for .doc file
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-17 20:55 UTC by Greg
Modified: 2023-11-17 22:26 UTC (History)
0 users



Attachments
problem file (33.50 KB, application/msword)
2023-11-17 22:25 UTC, Greg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg 2023-11-17 20:55:30 UTC
I'm getting the following exception when reading a .doc file:

java.lang.NullPointerException: Cannot read the array length because "<parameter1>" is null
	at java.base/java.lang.String.<init>(Unknown Source)
	at org.apache.poi.poifs.macros.VBAMacroReader$ModuleImpl.getContent(VBAMacroReader.java:175)
	at org.apache.poi.poifs.macros.VBAMacroReader.readMacros(VBAMacroReader.java:160)
	

I believe the code of module.read(in) here: https://github.com/apache/poi/blob/REL_5_2_2/poi/src/main/java/org/apache/poi/poifs/macros/VBAMacroReader.java#L232 may fix the issue.  I tried it in the debugger, and it seemed to resolve the NPE.

Thanks for your time and great work,

Greg
Comment 1 Tim Allison 2023-11-17 21:37:47 UTC
Any chance you can share a triggering file? Even if privately?

I feel like we should have heard about more NPEs from the community or our regression corpora if we were supposed to module.read(in) at that point. 

Have you tried using a more recent version of POI?
Comment 2 Tim Allison 2023-11-17 21:59:15 UTC
>I feel like we should have heard about more NPEs from the community or our regression corpora if we were supposed to module.read(in) at that point. 

That said, I trust your finding and would like to dig in. Thank you!
Comment 3 Greg 2023-11-17 22:25:13 UTC
Created attachment 39377 [details]
problem file
Comment 4 Greg 2023-11-17 22:26:59 UTC
Hi Tim, 

I think I misunderstood the attachment mechanism, but it should be that file above.  I would recommend not opening in word because it may contain malicious macros. Unfortunately, I tried this out in 5.2.4 as well with no luck.  Thanks for your help,

Greg