You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everybody,
I ran into a problem with the CIO HTTP-Client when getting responses where the HTTP header exceeds 2048 characters:
java.lang.IndexOutOfBoundsException: null
at java.nio.Buffer.checkIndex(Buffer.java:540)
at java.nio.DirectCharBufferS.get(DirectCharBufferS.java:253)
at io.ktor.http.cio.internals.CharBufferBuilder.getImpl(CharBufferBuilder.kt:21)
at io.ktor.http.cio.internals.CharBufferBuilder.get(CharBufferBuilder.kt:18)
at io.ktor.http.cio.internals.CharBufferBuilder.charAt(CharBufferBuilder.kt:6)
at io.ktor.http.cio.internals.TokenizerKt.findColonOrSpace(Tokenizer.kt:68)
at io.ktor.http.cio.HttpParserKt.parseHeaders(HttpParser.kt:81)
at io.ktor.http.cio.HttpParserKt.parseResponse(HttpParser.kt:54)
at io.ktor.http.cio.HttpParserKt$parseResponse$1.doResume(HttpParser.kt)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:53)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:53)
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161)
at kotlinx.coroutines.experimental.io.internal.MutableDelegateContinuation.run(MutableDelegateContinuation.kt:14)
at io.ktor.network.util.IOCoroutineDispatcher$IODispatchedTask.run(IOCoroutineDispatcher.kt)
at io.ktor.network.util.IOCoroutineDispatcher$IOThread$run$1.doResume(IOCoroutineDispatcher.kt:78)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161)
at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25)
at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:147)
at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:244)
at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Builders.kt:185)
at io.ktor.network.util.IOCoroutineDispatcher$IOThread.run(IOCoroutineDispatcher.kt:73)
The problem seems to be, that in CharBuffersBuilder the CHAR_BUFFER_SIZE from CharBufferPool is used mutliple times for offset calculation. As it turns out, this constant holds the size of the CharBuffer in bytes while the CharBuffer itself uses 16-bit characters. The code assumes the CharBuffer to be able to hold 4096 characters but this is acutally the size in bytes and the CharBuffer is only 2048 characters big. After reading 2048 characters from a response with a long header section, the code crashes.
The text was updated successfully, but these errors were encountered:
Hello everybody,
I ran into a problem with the CIO HTTP-Client when getting responses where the HTTP header exceeds 2048 characters:
The problem seems to be, that in CharBuffersBuilder the
CHAR_BUFFER_SIZE
from CharBufferPool is used mutliple times for offset calculation. As it turns out, this constant holds the size of theCharBuffer
in bytes while theCharBuffer
itself uses 16-bit characters. The code assumes theCharBuffer
to be able to hold 4096 characters but this is acutally the size in bytes and theCharBuffer
is only2048
characters big. After reading 2048 characters from a response with a long header section, the code crashes.The text was updated successfully, but these errors were encountered: