diff options
-rw-r--r-- | src/main/kotlin/NinePConnection.kt | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/kotlin/NinePConnection.kt b/src/main/kotlin/NinePConnection.kt index 04b489b..ccac9c5 100644 --- a/src/main/kotlin/NinePConnection.kt +++ b/src/main/kotlin/NinePConnection.kt @@ -65,11 +65,13 @@ class NinePConnection(netPackTrans: NetworkPacketTransporter) : NinePTranslator * In 9P, strings are represented as a 2-byte integer (the string's size) followed by the actual UTF-8 string. The * null terminator is forbidden in 9P messages. * - * @return The string. + * @return the string. + * @throws java.io.IOException if the message could not be correctly received. */ private fun readString(): String { - val length = readInteger(2).toInt() - return String(this.npt.receiveFixed(length.toULong()).toByteArray()) + val length = readInteger(2u).toShort().toUShort() + val rawString = this.npt.receive(length.toULong()) + return String(ByteArray(rawString.size) { i -> rawString[i].toByte() }) } /** |