Author: centic
Date: Wed Sep  6 14:33:59 2023
New Revision: 1912138

URL: http://svn.apache.org/viewvc?rev=1912138&view=rev
Log:
Bug 66425: Avoid a NullPointerException found via oss-fuzz

We try to avoid throwing NullPointerException, but it was possible
to trigger one here with a specially crafted input-file

Added:
    
poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx
   (with props)
Modified:
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
    poi/trunk/test-data/spreadsheet/stress.xls

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java?rev=1912138&r1=1912137&r2=1912138&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
 (original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
 Wed Sep  6 14:33:59 2023
@@ -78,11 +78,12 @@ public class XWPFParagraph implements IB
                     XmlObject o = c.getObject();
                     if (o instanceof CTFtnEdnRef) {
                         CTFtnEdnRef ftn = (CTFtnEdnRef) o;
-                        footnoteText.append(" 
[").append(ftn.getId()).append(": ");
+                        final BigInteger id = ftn.getId();
+                        footnoteText.append(" [").append(id).append(": ");
                         XWPFAbstractFootnoteEndnote footnote =
                                 
ftn.getDomNode().getLocalName().equals("footnoteReference") ?
-                                        
document.getFootnoteByID(ftn.getId().intValue()) :
-                                        
document.getEndnoteByID(ftn.getId().intValue());
+                                        document.getFootnoteByID(id == null ? 
0 : id.intValue()) :
+                                        document.getEndnoteByID(id == null ? 0 
: id.intValue());
                         if (null != footnote) {
                             boolean first = true;
                             for (XWPFParagraph p : footnote.getParagraphs()) {
@@ -93,7 +94,7 @@ public class XWPFParagraph implements IB
                                 footnoteText.append(p.getText());
                             }
                         } else {
-                            footnoteText.append("!!! End note with ID 
\"").append(ftn.getId()).append("\" not found in document.");
+                            footnoteText.append("!!! End note with ID 
\"").append(id).append("\" not found in document.");
                         }
                         footnoteText.append("] ");
 

Added: 
poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx
URL: 
http://svn.apache.org/viewvc/poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx?rev=1912138&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
poi/trunk/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Wed Sep  6 14:33:59 2023
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.wordprocessingml.document

Modified: poi/trunk/test-data/spreadsheet/stress.xls
URL: 
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/stress.xls?rev=1912138&r1=1912137&r2=1912138&view=diff
==============================================================================
Binary files - no diff available.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to