From e666d3756eaea55a138e7b2b319bc70ad28bf74d Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 11 Sep 2023 18:25:06 +0000 Subject: [PATCH] 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 Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62208 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912251 13f79535-47bb-0310-9956-ffa450edef68 --- .../ReadOnlySharedStringsTable.java | 6 ++++-- ...mized-XLSX2CSVFuzzer-6504225896792064.xlsx | Bin 0 -> 10245 bytes test-data/spreadsheet/stress.xls | Bin 51712 -> 52224 bytes 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/clusterfuzz-testcase-minimized-XLSX2CSVFuzzer-6504225896792064.xlsx diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java index 07d00bd99a..590251960a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java @@ -259,7 +259,7 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared } else if ("rPh".equals(localName)) { inRPh = true; //append space...this assumes that rPh always comes after regular - if (includePhoneticRuns && characters.length() > 0) { + if (includePhoneticRuns && characters != null && characters.length() > 0) { characters.append(" "); } } @@ -287,7 +287,9 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared public void characters(char[] ch, int start, int length) throws SAXException { if (tIsOpen) { if (inRPh && includePhoneticRuns) { - characters.append(ch, start, length); + if (characters != null) { + characters.append(ch, start, length); + } } else if (! inRPh){ if (characters != null) { characters.append(ch, start, length); diff --git a/test-data/spreadsheet/clusterfuzz-testcase-minimized-XLSX2CSVFuzzer-6504225896792064.xlsx b/test-data/spreadsheet/clusterfuzz-testcase-minimized-XLSX2CSVFuzzer-6504225896792064.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..9426600d727a44b965acfa69d6e145c32621630c GIT binary patch literal 10245 zcmeHtWmKEn)^6}(MGD1&I~1otfl|CdLeUl}#kELqhvH6g4N%;nKyfMV?vP?difeKE z(w;NU?(W{_8~5Iy=bn}1O)|zipN!1)Oj&bIML8s70st!D9smHK2H4zx!U{nE06w4q z01p5#1T6_`D|;g=dmU95h>@K(yR)SQRpvAT(+2<|{Qm#0|11p*#DW#tIdT2ZKwqej z9@1Nd`r(?-p*)kzM+Uac#B>!JXi?OBsxgTk!B7lR9YaZxRN~!lx-j0^bk|BUL_(;l zd_rbI8~-j&!K`6mcDrA~br3(SjYSXY58VaKx;uLEdCa=B_!Y9P7l(~5LLw^sWOdht z)h|_Q6@x+Pdc94NtmVieB;lpC_Iy6!X2p+ZEG{Jxd|pOAk_>vENkiHESU8&W)3A-S z>!UhL%(wec^!@O78fDw&@~yzPTOs0diVCHyM}4H_p_=}8=0P?l05q)(94dl%KsmPt zYrRvmuXr(7ey>LIgFi*fl1+(6+dzJW8KvBAd3Q#-_Olo#qL554 zei>iFW9T?u?-h*!QX0eD>lfeess(Il)OUJ^CA$FqM+urQyrUmCsL&9J4{FcFn z=X$N3II24EZTl+!MOY z5PFn=+5PP7G2Jp|8wyM41pD`70}|3r2bU@AK4EYT_x0pE{aogVI3GwcAC-dd`=PtH z4fR%X?lx;C@8iqVd#s6u3~`@?Y>iN{CTh}k_c8=`P?fc>@(1)L=vI)m8_IFQ9_#gN zyqgpXOcbv#HlKRqA+cG1NW9VaB9FA^ecD5l*N98vPRlNw0@`L2}{lVWL5EZ8z|IDbCtpT;cDFx7J;8W zo22Gv+`GS8(Xeo6XdJz^rOteWJ|&Z-B1q90`)(*a(lveTY;b&#jef|Et(Kcq*%k5m ztJ#yuipQr1dIR26-j2*{O=Uz%t4H`Od(ye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nvaMu~kax7Sk%I@wyj z)-(h$#CCN9{AZ9t$Zl5T*_17)qL2mzXmqK~GmY8l=SZtj86Tm&EKIBpI8Wr`ei>H@ zq1?TCh}f%zHtv$q%tH-$6vheW-x< zDnfY4u8K4GR@|M7VUGlL0l{SU5ZvvqlikF7Rl^$@VLgcxa&b#_xzB|gN;p#=;P_K&WyZOoB0z)IJ5py zph7@ogV#*{e#q%}`u)wwlcL<80scIx@hgBk+$w&V+xT7Z&u#Bt1x?}Yvwz HAK(55x$f## literal 0 HcmV?d00001 diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index d1b01472d316f509f037976e9cec613599012f6d..b797f92f285ca83ecb5ab49a1efe63f57919f11b 100644 GIT binary patch delta 2787 zcmZ9NYfKbZ6vyw~2T+8L6m@IOO|hv~T+v+w790>%Ku|zX5Ks_yVYO6b6?{Og6|uHj zwZ$GynwUoWjv|^eE7TWA8zhZu+pnhaL(}w=@k5iErfn=ebN9e9vy(lU^Sl3Z{`WDn z+kMvB{js&z72m|@Gm|mzH#xc1*^LPPo0yoG{5I>kcE);oq~*-`3>UwimZp?b+-z z&fuq#qu?sDYjvf9D?hL~(Tv66r2a@@?0fBa*;anow{f;UO?C(eI9@*|L~;wWu&1$+ z+{&!XH!Zg@8}luUjN6%=<#x@P>KDbLSl_(JIJ)z`m~hT4&+9r1d!RL!ca_hLvCL%m z5k#{ETp!5e3e#Cg`|;uv>)~g(k@~QMEyCe `Z6V5D{C1S=cQK+kzKq!Csw`>8%%Frne5k;1}LxTm|Ng z^~iV;_3^k2!4ziI9Z||ccrm8seObfjKNXR!;`-Lkh~#z@_h~o2`rM){rVY@`9n1+k zFD3IOaPE?mr@$!2rSJsfGMIbW$z4!@(G7bp&*Q0Z8sl=fba|dg#U8^rmuOtgOL*Dj zX2sxC94rlfmFj00(_wC3ME#sW9V^utP|>IN-i6TvC#I=q7}WYfIanr)O7$a*S@8EX zb-Y2XKN}9V0^C>h-lZ5-Xt@%Z3GU#ud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