From cd797f81167b6b1b1229577d5764b0ca1fb0b039 Mon Sep 17 00:00:00 2001 From: Randy Date: Mon, 11 Mar 2019 23:56:45 +0100 Subject: [PATCH 1/3] add fuzz target, dictionary, iphone png's --- tests/pngsuite/iphone/iphone_basi0g01.png | Bin 0 -> 384 bytes tests/pngsuite/iphone/iphone_basi0g02.png | Bin 0 -> 302 bytes tests/pngsuite/iphone/iphone_basi3p02.png | Bin 0 -> 303 bytes tests/pngsuite/iphone/iphone_bgwn6a08.png | Bin 0 -> 2573 bytes tests/pngsuite/iphone/iphone_bgyn6a16.png | Bin 0 -> 2267 bytes tests/pngsuite/iphone/iphone_tbyn3p08.png | Bin 0 -> 1558 bytes tests/pngsuite/iphone/iphone_z06n2c08.png | Bin 0 -> 2393 bytes tests/stb_png.dict | 30 ++++++++++++++++++++++ tests/stb_png_read_fuzzer.cpp | 19 ++++++++++++++ tests/stb_png_read_fuzzer.options | 2 ++ 10 files changed, 51 insertions(+) create mode 100644 tests/pngsuite/iphone/iphone_basi0g01.png create mode 100644 tests/pngsuite/iphone/iphone_basi0g02.png create mode 100644 tests/pngsuite/iphone/iphone_basi3p02.png create mode 100644 tests/pngsuite/iphone/iphone_bgwn6a08.png create mode 100644 tests/pngsuite/iphone/iphone_bgyn6a16.png create mode 100644 tests/pngsuite/iphone/iphone_tbyn3p08.png create mode 100644 tests/pngsuite/iphone/iphone_z06n2c08.png create mode 100644 tests/stb_png.dict create mode 100644 tests/stb_png_read_fuzzer.cpp create mode 100644 tests/stb_png_read_fuzzer.options diff --git a/tests/pngsuite/iphone/iphone_basi0g01.png b/tests/pngsuite/iphone/iphone_basi0g01.png new file mode 100644 index 0000000000000000000000000000000000000000..33db08c5b3e519239a589541910760cb3081189c GIT binary patch literal 384 zcmeAS@N?(olHy`uU|?}hck&EiP+-&9QJx0m^Ll!?1OaIU5awWGU|?ja^-2PASkfJR z9T^xl_H+M9WCijWi-X*q7}lMWc?nXP>=ES4z)+>ez|hdb!0-zw)bN6Vq11qZ;Z*_y zgVhWM2JwP9y8>;167M`+97B$VF!Hq+a6JA$|60bPnLHYcXXxInEM7AuO08Y0=zoXI z`QUqVvp?>s5KlfLpy}D;f8>YL!?T`FV#17*x6cdf@{}$&b~3O$pyhMu-m@c)^Z&2} zSS?B2V3$%MAezZI#aknLLek{3GnhJ7v@s<1X0*L(bY%45$xu#ZjN$!qcgve2lX`XK zE1q6iZ+eV<%0wk!g@)_g*XnE5t}}4BD`Di2)XKA>OpU+zJEQS7!3M61vvcnHtDh5c zcwO{pKWBhi%*&NUNhyb}p4z_k;kN1qzZlgE@A}_$?X3`Bu3fmB>1w{0_JLWe);P>w cef{~iBj0TpdBQeq1p1u8)78&qol`;+0Lqq-JOBUy literal 0 HcmV?d00001 diff --git a/tests/pngsuite/iphone/iphone_basi0g02.png b/tests/pngsuite/iphone/iphone_basi0g02.png new file mode 100644 index 0000000000000000000000000000000000000000..484f46d248d08f3ed1f67e41dfc08af88e6cc83f GIT binary patch literal 302 zcmeAS@N?(olHy`uU|?}hck&EiP+-&9QJx0m^Ll!?1OaIU5awWGU|?ja^-2PASkfJR z9T^xl_H+M9WCijWi-X*q7}lMWc?nXP>=ES4z)+>ez|hdb!0-zw)bN6Vq11qZ;Z*_y zgVhWM2JwP9y8>;15_3FV97EoQFmfGG;Mn8;?WEmJtu&qEIUXg_CK5@{U#3bjERjgg z+E%>jsD)C?gj4Eb;mdDK7gSAjEe?A7m{XwMiH&>BzYQ&{*K+^4HS3&M#Insu?48;? zi#;v}AF6Wgt2S87{zvVTe`9^mZ@D+s24Ce~FvzYDzBlXT^U16NWq1CUFs|m#vWq|P us%h4FaR+(lT@1e@F0o!XK0z;`^x*lu%y-rLu%tWs zIx;Y9?C1WI$O_~$76-XIF|0c$^Ae;o*(1o8fuTx`fuW&=f#DZWsNn?zL#Y7+!>a@a z2CEqi4B`cIb_Lo1CFXj%IEK6pzR7n$f#dQ2`dP6S?lZP;)+^+f>T_bBI-{fWyMJDl z)b+V%ENmv7Fn6#tHi|fRxsr8?EKkMmtxh6mBXu9K)E_yRzI(x!^yfUsHO&nr^xtMY z+InTL#C4uq=>~@d9!58;FMOHsa=~i8d;ffy&;AQt7-cih;eFH5ADkRD){j)={1Z03 s(2?_H_{Z~*MXjQ(fT`IvJvIYGeoSDJetfxE1n5u(Pgg&ebxsLQ05`{JsQ>@~ literal 0 HcmV?d00001 diff --git a/tests/pngsuite/iphone/iphone_bgwn6a08.png b/tests/pngsuite/iphone/iphone_bgwn6a08.png new file mode 100644 index 0000000000000000000000000000000000000000..7d0ac50be96a9cd46906abf146d02288ebd44cd8 GIT binary patch literal 2573 zcmaKu3sh8f9>>4`duQ$p^Md6K4lqri@{-9g5D^DtlJ_e407SYa`M^h`h)zcO&&5J= zOALk7iX|UlfMc1GQvG*Vi_jEJ6NNo{*B)Y7QfX4bZhv<7?Cv?cXXl(d_uPB__kVx? z@BjPzeD9W-c{7ZyL}^u=kJGhq>;FTJ^uUmG(s()0P*GJ0qw{$IX+{cV0yEl$l% z1rEQUAAUs5uSt3Sj5M^LHQyK=xiBL?7g#?QpjE(6{1zPmDr~@)GLX~&1UUB`pOp-F zJeirEI@|HdxyN@^;Dc{(eXn1V{dE4-lodg5?6{J4x#*L#JEIP_zO>-O<4HN^@5!5S zq_FwQ&c7^*dA8!(<4yCeWk(zP$o0(&%$ki=OXAJ(_na5c`>em#RU7^8!XM6D|K786 z`}LnkDyO9l-z|(uOEjkq91rg-$s8Klu9YHwrTft8UF(RCdafYHe@m4$Khm-H8`GyNm{k!+GZ*hD&x zBtM2y1Vc|#uoijz6>IP*lJSE$NE%dLu!*vXB~u4Z;}4jNR>2j_lBf?JASbb$xI&p8 zB@>~;{WN7kz*=5o64s3me}W7lha}czbd|T%b;6>u?D;6Fwm5IHB!{pE4>!LOwc}#j z>cXi;CFiY!`^qM*I8k!>0?sDv-k;sJ^G4Q*6<5Drb7r2A>KZlF$SiagLg9n`I3qM@ z+$xJf8BZr+9QFuanr$klKYM_NAb=E0ZoLvkkC95Pl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^c{^z`_hE35N=ET7e085woyL{rg;ab;Ss%P^CPlQp>$#`xwlt`=Cs~Qc0ZKJBGx$LE*%M7J25MT5QP7S+^Z%Buy zG6mCucpk)I3IhIDq)RFi5k1Bs$VEswDW^TLAgIJ$)1`?-8RG?b_5 ze+Mpyh(C`Q;XeYmfD_J5lpvfFs>MVjFYd8#!I45ZwsD(pvYYTy1SjuFjyF+}6r!k| zV5z)0hWQqpfy=RFEyAOvHt?vc@WjgZG+tcJtzW|+~NbCRr literal 0 HcmV?d00001 diff --git a/tests/pngsuite/iphone/iphone_bgyn6a16.png b/tests/pngsuite/iphone/iphone_bgyn6a16.png new file mode 100644 index 0000000000000000000000000000000000000000..9046336a89ee08db49c7204c0279f74d239b86b9 GIT binary patch literal 2267 zcmV<12qgE3P)Px#AY({UO#lFTCIA3{ga82g z0001h=l}q9FaQARU;qF*m;eA5aGbhPJOBU)Nl8RORLz&qN^)%%hnJfF+Ud@=WoouD zD=kg4L@KOc7ZOGPtf+`0u%e(zISC?YAk?IpG-%eqNsT=P51~`&5T5CG`6(X{`#XU5 zRjy_a&*gou^;_!}`B!{;dwZo<1#bsWhn@~fhi-6paCLBYaCERkR|i`MYX?h*&i8*G z6@h3pDp4JVAp%1Xf*=e+00zJh8uWn=RPcfadO!g;xWEYx=mHy9!2*2MzXiMq=m=!9 zS;=N#3X(7ZaTtRbL_voLgdqq4=m!mapn?Y!aDx-;V&KuXqSF>F(uMTE=nm<5IqNFq=`U<-kAxh&;V zID$Rcf;CuyC76dCq+tR^L5C3dL4|IxgOqJsQnD8~i=EFrLkz!?Jf2)rUtuh*si4lnQk*KiCQP=FLfzzb4W zUZv){m#Y7a3)zygwj?Frv>2Wk%^5HYbR#g(3L*s32rMA5hQJ{LHwZi-@Qy&E(U8U` zyukxpzz!534jM?q`!4l?C#i*Qq#8byN@z{WfdzUaEe5fbRR$z#@BUlBjes8k9f3&% z@(8RTu#3Ps0(S_!An=Jmv)Pp97ren8?86*{L7Lj9G$JojAGwoS>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002ovPDHLkV1i7(uGjzo literal 0 HcmV?d00001 diff --git a/tests/pngsuite/iphone/iphone_tbyn3p08.png b/tests/pngsuite/iphone/iphone_tbyn3p08.png new file mode 100644 index 0000000000000000000000000000000000000000..3c224d092e41a36a81ae79b27f6b3a92bc4d283c GIT binary patch literal 1558 zcmV+x2I={UP)Px#AY({UO#lFTCIA3{ga82g z0001h=l}q9FaQARU;qF*m;eA5aGbhPJOBU%gh@m}RP9%7NR?+8e)=F$q$Ded_9G#p z0)^l}Q4~`SCDl@M9XXMpVjp;@B=aM`mE*_pOizBF@~c{rF&5>B*4S`k%}tQ?!#2ji z7{nG>>E^Z&DXu-&{l4!(aGo{i+MhjebKdj%`d-(4-Pe6T&r$0CHOKYn(IX5F4q{?r z0PrHR9rWQBu;6k&!3!PiAav4E_E6@OV5pcI+5Z zQ**F$X8~5O^lGpM9c~@v=BFQCxA|F)Wy=Z>9eoNRAxVKCnI%h_aP(*)E?&Hd`}gl-a&j^_89u<8Ubt`pd3kxr z$;pvy3CfolpjUPD=@>HOuH2&4j1;dZ-GR8$0qqg+4uBfO$Rc#d-8XClSRORg1vvUqAnvs!#g9i^HF)Y70>JU{@o+kwvzxK5t`6!0 z1vQ}KSA{*F?m<&ilXOFSdplZMT2NC{gW}@ipux_e+{GIxzm!9@sS1{ zR0@qcj+;Rey}iA&6ChCdrEo)qp9~Utm-D0yEQkHF9r4%W;k)KTcXu~BJ3GZIBtW?j z9XbT3mi(LWaQv(Rdvv5OT!=SALXe@aoom)$_}k&x36NcsKMLwS4gQruz$ycQ)yMkY zb%mIg7<6@Yp{J)u1`TU2;JUuoVq%~XBzuByTD=-?L`K3976!+bEy1TF=R9AoE^DA0 zrV78PK=wk)udvm>RkEiFByr}<83A|g-;dulD6>DYXc1z!Z4=|gu39DX(;Ksba}5j( zz*c30x}|~Yb$o4@ac|pR=?e9wL10Jo4)Fq2APG*p>DgbQ+)+_@D>haP*kgL(k|rIL z05_1hf;fXfxsJPr0uhZ71_5?QyFq}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WCZ1Yc=3+#VDU{ouYK!vgoE4> z(Cz5_ia-^7Q-AyZwN{#{zeaE28OjkNfn^AnX-_4}(0uq`*~x6M@Cg@uz-%(Aw#;Y| z{Y~9;LPkn1=eto|D&rzp*dP{mt{1%jLaG5_k zLu;Ue^B@Lz7I+JBQIlsex}8Nc)aTgyW@$lv>zGMn`i%A%M`t=_=J?mDW9)~-2?M_e zV_){^DAj*Zd^s>@8uLc`5%JxZz+V6!;-DtZqD3$rx&vx+`IlK&OmATpUfIAHNYlGAcY^`B~IdUH>X<^aK?Ld4i{aP{c`16265# z%DinooT4&uNPfP>hn2|_P)HoF!zyrM}h^!8|tpB=$vIm5n$aGno-I@%;k5FX--xy!|o zX%>~!bkBigfBjF!rYd@q93vb=r)`;JB}N0ML2LN>H~7ccOQ?hgwEV&ekGgkfAD>XV za06vIyh(g;Z1g*toRIG@9A4NC;iQc;H?He?BR==SfwbbN(8Pq<$soj@NmQZ*#zj}{ zCiFgyNIRr%wvPEwlwKTbD5)h*6gB9pmR(!wTgn@;SBK5rlOl;7*tnX(7OQ~w+dT?7 zAJo06jU-(r<&7ItF*10_jJ-?ts6=ko$w-<9Jr2{a^n7E=@+v(TA}6b?Tvg|XOPoEf zdYb#B$T1x!;`XZD0|S=YLZuwby2u~o*vmC}4Qh`9fQ776`wiV}Tn})hh9Pxra|n6o z7gL1(a#xC@w}TWDjEf!{<8sVQIVNHDDHM#fG%i@}%*fS>(9$ULMD`C9Y^5x(Sncu= zu==CKLp6V@rQ0=qHNE5~`Tc>pZojE z^WnmEl`iAGBVS}Pw7E7u1~b1@e}4OV)AI$?6J1cj(~g3dUq7{d0q&|ECvW_9fZf3n J+>30X (80000000 / 4) / y) return 0; + + unsigned char *img = stbi_load_from_memory(data, size, &x, &y, &channels, 4); + + free(img); + + return 0; +} diff --git a/tests/stb_png_read_fuzzer.options b/tests/stb_png_read_fuzzer.options new file mode 100644 index 0000000..e0c8a84 --- /dev/null +++ b/tests/stb_png_read_fuzzer.options @@ -0,0 +1,2 @@ +[libfuzzer] +dict = stb_png.dict From af516b99ffdd3b01c7a77b1673a871aa7503d761 Mon Sep 17 00:00:00 2001 From: Randy Date: Tue, 12 Mar 2019 00:14:16 +0100 Subject: [PATCH 2/3] fuzz: remove some chunk identifiers from stb_png.dict these chunks are not parsed --- tests/stb_png.dict | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tests/stb_png.dict b/tests/stb_png.dict index 3f5e673..2a27994 100644 --- a/tests/stb_png.dict +++ b/tests/stb_png.dict @@ -5,26 +5,4 @@ section_iend="IEND" section_ihdr="IHDR" section_plte="PLTE" section_trns="tRNS" -section_chrm="cHRM" -section_gama="gAMA" -section_iccp="iCCP" -section_sbit="sBIT" -section_srgb="sRGB" -section_text="tEXt" -section_ztxt="zTXt" -section_itxt="iTXt" -section_bkgd="bKGD" -section_hist="hIST" -section_phys="pHYs" -section_splt="sPLT" -section_time="tIME" -section_offs="oFFs" -section_exif="eXIf" -section_frac="fRAc" -section_pcal="pCAL" -section_scal="sCAL" -section_ster="sTER" -section_gifg="gIFg" -section_gift="gIFt" -section_gifx="gIFx" section_cgbi="CgBI" From 06374082843275af71e1ccc4ca28e13fe3e51ed7 Mon Sep 17 00:00:00 2001 From: Randy Date: Tue, 12 Mar 2019 00:59:20 +0100 Subject: [PATCH 3/3] fuzz: fix error handling --- tests/stb_png_read_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stb_png_read_fuzzer.cpp b/tests/stb_png_read_fuzzer.cpp index 613eeb8..0e14e1b 100644 --- a/tests/stb_png_read_fuzzer.cpp +++ b/tests/stb_png_read_fuzzer.cpp @@ -6,7 +6,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { int x, y, channels; - if(stbi_info_from_memory(data, size, &x, &y, &channels)) return 0; + if(!stbi_info_from_memory(data, size, &x, &y, &channels)) return 0; /* exit if the image is larger than ~80MB */ if(y && x > (80000000 / 4) / y) return 0;