java.util.zip.ZipException

864 views
Skip to first unread message

ADK

unread,
Nov 25, 2014, 1:41:16 AM11/25/14
to ra...@googlegroups.com
Railo 4.2.2.002 update cause error in this CFLib function:

http://www.cflib.org/udf/ungzip

example stacktrace:

too many length or distance symbols at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164):164 at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:116):116 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method):-2 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57):57 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43 at java.lang.reflect.Method.invoke(Method.java:606):606 at railo.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:53):53 at railo.runtime.reflection.Reflector.callMethod(Reflector.java:855):855 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:754):754 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1563):1563 at index_cfm$cf.udfCall(C:\dev\apps\test\index.cfm:31):31 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:109):109 at railo.runtime.type.UDFImpl._call(UDFImpl.java:323):323 at railo.runtime.type.UDFImpl.call(UDFImpl.java:224):224 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:764):764 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:740):740 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1563):1563 at index_cfm$cf.call(C:\dev\apps\test\index.cfm:10):10 at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:925):925 at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:877):877 at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:222):222 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:34):34 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2228):2228 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2195):2195 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:347):347 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51):51 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243):243 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502):502 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100):100 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408):408 at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603):603 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310):310 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145):1145 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615):615 at java.lang.Thread.run(Thread.java:745):745

Reverting back to 4.2.1.008 fixes this.

Michael Offner

unread,
Nov 25, 2014, 2:29:22 AM11/25/14
to ra...@googlegroups.com
This exception is happening while reading a file with help of a gzip inputstream but not inside Railo, this is happening while calling the Java code directly within a udf. are you a 100% sure downgrading solve the issue and this was not a coincidence?
Micha
--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/ec83e623-927d-4cab-aaed-081cd930ff2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ADK

unread,
Nov 25, 2014, 4:59:59 PM11/25/14
to ra...@googlegroups.com
Hi Micha. I am 100% certain. Consider the following code:

theString = "Railo is great!";
echo("Original String: " & theString & "<br>");

zippedFile
= gzip(theString); // uses another UDF to gzip the string
echo("GZipped String: " & zippedFile & "<br>");

unzippedFile
= ungzip(zippedFile);
echo
("Unzipped String: " & unzippedFile);

function ungzip( String string='', String encode = 'base64' ){
   
try {
       
var bufferSize=8192;
       
var byteArray = createObject("java","java.lang.reflect.Array").newInstance(createObject("java","java.lang.Byte").TYPE,bufferSize);
       
var decompressOutputStream=createObject("java","java.io.ByteArrayOutputStream").init();
       
var input=0;
       
var decompressInputStream=0;
       
var l=0;
       
if(not isBinary(arguments.string) and arrayLen(arguments) is 1) return;
       
if(arrayLen(arguments) gt 1){
            input
=binaryDecode(arguments.string,arguments.encode);
       
}else{
            input
=arguments.string;
       
}
        decompressInputStream
=createObject("java","java.util.zip.GZIPInputStream").init(createObject("java","java.io.ByteArrayInputStream").init(input));
        l
=decompressInputStream.read(byteArray,0,bufferSize);
       
       
while (l gt -1){
            decompressOutputStream
.write(byteArray,0,l);
            l
=decompressInputStream.read(byteArray,0,bufferSize);
       
}
        decompressInputStream
.close();
        decompressOutputStream
.close();
       
       
return decompressOutputStream.toString();
   
}
   
catch (any e){
        writeDump
(e);
   
}
}

Run on 4.2.1.008 and you get:

Original String: Railo is great!
GZipped String: H4sIAAAAAAAAAAtKzMzJV8gsVkgvSk0sUQQA3bbHAQ8AAAA=
Unzipped String: Railo is great!

Run it on 4.2.2.002 and you get:

Original String: Railo is great!
GZipped String: H4sIAAAAAAAAAAtKzMzJV8gsVkgvSk0sUQQA3bbHAQ8AAAA=
 

Catch
additional
Struct
Cause
string java.util.zip.ZipException


Detail
string


ErrorCode
string 0

Extended_Info
string


ExtendedInfo
string


Message
string invalid stored block lengths

StackTrace
string invalid stored block lengths at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164):164 at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:116):116 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method):-2 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57):57 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43 at java.lang.reflect.Method.invoke(Method.java:606):606 at railo.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:53):53 at railo.runtime.reflection.Reflector.callMethod(Reflector.java:855):855 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:754):754 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1563):1563 at index_cfm$cf.udfCall(C:\dev\apps\test\index.cfm:24):24 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:109):109 at railo.runtime.type.UDFImpl._call(UDFImpl.java:323):323 at railo.runtime.type.UDFImpl.call(UDFImpl.java:224):224 at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:764):764 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:740):740 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1563):1563 at index_cfm$cf.call(C:\dev\apps\test\index.cfm:6):6 at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:925):925 at railo.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:55):55 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:35):35 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2228):2228 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2195):2195 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:347):347 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51):51 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243):243 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502):502 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100):100 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408):408 at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603):603 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310):310 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145):1145 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615):615 at java.lang.Thread.run(Thread.java:745):745

TagContext
Array
1
Struct
codePrintHTML
string 22: }<br> 23: decompressInputStream=createObject(&quot;java&quot;,&quot;java.util.zip.GZIPInputStream&quot;).init(createObject(&quot;java&quot;,&quot;java.io.ByteArrayInputStream&quot;).init(input));<br> <b>24: l=decompressInputStream.read(byteArray,0,bufferSize);</b><br> 25: <br> 26: while (l gt -1){<br>

codePrintPlain
string 22: } 23: decompressInputStream=createObject("java","java.util.zip.GZIPInputStream").init(createObject("java","java.io.ByteArrayInputStream").init(input)); 24: l=decompressInputStream.read(byteArray,0,bufferSize); 25: 26: while (l gt -1){

column
number
0

id
string ??

line
number
24

Raw_Trace
string index_cfm$cf.udfCall(C:\dev\apps\test\index.cfm:24)

template
string C:\dev\apps\test\index.cfm

type
string cfml


2
Struct
codePrintHTML
string 4: zippedFile = gzip(theString);<br> 5: echo(&quot;GZipped String: &quot; &amp; zippedFile &amp; &quot;&lt;br&gt;&quot;);<br> <b>6: unzippedFile = ungzip(zippedFile);</b><br> 7: echo(&quot;Unzipped String: &quot; &amp; unzippedFile);<br> 8: <br>

codePrintPlain
string 4: zippedFile = gzip(theString); 5: echo("GZipped String: " & zippedFile & "<br>"); 6: unzippedFile = ungzip(zippedFile); 7: echo("Unzipped String: " & unzippedFile); 8:

column
number
0

id
string ??

line
number
6

Raw_Trace
string index_cfm$cf.call(C:\dev\apps\test\index.cfm:6)

template
string C:\dev\apps\test\index.cfm

type
string cfml



type
string java.util.zip.ZipException

 

Revert back to older version of Railo and works fine again.

Michael Offner

unread,
Nov 26, 2014, 1:27:44 AM11/26/14
to ra...@googlegroups.com
We will check what is going on ...
--
/micha

Michael Offner CTO Railo Technologies GmbH

Michael Offner

unread,
Nov 26, 2014, 4:58:39 AM11/26/14
to ra...@googlegroups.com
FYI

the problem is the fix for this ticket
this has affected the function "binaryDecode" that is used within the UDF.

to decode a base64 string we have moved away from a apache library, because this library was not complaining about invalid inputs.

Problem is solved for next release

Micha





For more options, visit https://groups.google.com/d/optout.

ADK

unread,
Nov 26, 2014, 2:57:15 PM11/26/14
to ra...@googlegroups.com
Thanks Micha - I saw 3225 and assumed it was the culprit, but my limited java skills prevented me from going much further in addressing it. I appreciate you looking into it.
...

AJ Mercer

unread,
Dec 4, 2014, 7:15:22 PM12/4/14
to ra...@googlegroups.com
4.2.2.003 is out with this patch

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages