#191 limit on the size of hl7 message which can be recieved

2.2
closed-fixed
None
5
2013-06-26
2013-06-25
No

If a message larger than 4K is received then an ArrayIndexOutOfBoundsException will be thrown from AbstractHl7OverHttpDecoder

Below is the meaningful part of the stack trace
SEVERE: Servlet.service() for servlet OrderRequestServlet threw exception
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:428)
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193)
at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readBytesNonChunked(AbstractHl7OverHttpDecoder.java:375)
at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.doReadContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:196)
at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:426)
at ca.uhn.hl7v2.hoh.raw.server.HohRawServlet.doPost(HohRawServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

The error seems to be on lines 370 to 373 of that file

370 int max = buffer.length;
371 if (myContentLength > 0) {
372 max = myContentLength - bos.size();
373 }

The buffer has been set to a length of 4K

356 byte[] buffer = new byte[IOUtils.DEFAULT_BUFFER_SIZE];

but if myContentLength (set by the content length in the header) is greater than 4K then max will
greater than the size of the buffer and the following will fail with the exception

375 int bytesRead = theInputStream.read(buffer, 0, max);

Discussion

  • James Agnew

    James Agnew - 2013-06-26
    • status: open --> closed-fixed
    • assigned_to: James Agnew
     
  • James Agnew

    James Agnew - 2013-06-26

    Thanks for reporting Paul!

    A fix has been checked in.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks