diff options
author | Edoardo La Greca | 2025-08-01 17:00:42 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-01 17:00:42 +0200 |
commit | a18d9f1149dfda07c1bdd8fd50dbe20c83f25741 (patch) | |
tree | 3a6df5008c0580ca5f5241901b1032e86520e175 /src | |
parent | 4fdbf455652824b5060a6168103b93ef227985df (diff) |
fix types in readString
Diffstat (limited to 'src')
-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() }) } /** |