Skip to content
Snippets Groups Projects
Commit 6c308ae4 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixed a bug where quassel violates the QtDatastream protocol

parent b5729f45
Branches
Tags
No related merge requests found
......@@ -64,12 +64,6 @@ object DateTimeSerializer : Serializer<Temporal> {
.with(JulianFields.JULIAN_DAY, julianDay)
.with(ChronoField.MILLI_OF_DAY, milliOfDay)
.toInstant()
TimeSpec.OffsetFromUTC ->
Instant.EPOCH.atOffset(
ZoneOffset.ofTotalSeconds(IntSerializer.deserialize(buffer, features)))
.with(JulianFields.JULIAN_DAY, julianDay)
.with(ChronoField.MILLI_OF_DAY, milliOfDay)
.toInstant()
else ->
Instant.EPOCH.atOffset(ZoneOffset.UTC)
.with(JulianFields.JULIAN_DAY, julianDay)
......
......@@ -89,7 +89,7 @@ abstract class StringSerializer(
null
} else {
val limit = buffer.limit()
buffer.limit(buffer.position() + len - trailingNullBytes)
buffer.limit(buffer.position() + Math.max(0, len - trailingNullBytes))
val charBuffer = charBuffer(len)
decoder.reset()
decoder.decode(buffer, charBuffer, true)
......
......@@ -14,6 +14,7 @@ import de.kuschku.libquassel.util.compatibility.HandlerService
import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.*
import de.kuschku.libquassel.util.compatibility.log
import de.kuschku.libquassel.util.hasFlag
import de.kuschku.libquassel.util.helpers.hexDump
import de.kuschku.libquassel.util.helpers.write
import de.kuschku.libquassel.util.nio.ChainedByteBuffer
import de.kuschku.libquassel.util.nio.WrappedChannel
......@@ -191,10 +192,12 @@ class CoreConnection(
session.handle(msg)
} catch (e: Throwable) {
log(WARN, TAG, "Error encountered while handling sigproxy message", e)
log(WARN, TAG, msg.toString())
}
}
} catch (e: Throwable) {
log(WARN, TAG, "Error encountered while parsing sigproxy message", e)
dataBuffer.hexDump()
}
}
......@@ -207,9 +210,11 @@ class CoreConnection(
session.handle(msg)
} catch (e: Throwable) {
log(WARN, TAG, "Error encountered while handling handshake message", e)
log(WARN, TAG, msg.toString())
}
} catch (e: Throwable) {
log(WARN, TAG, "Error encountered while parsing handshake message", e)
dataBuffer.hexDump()
}
}
}
package de.kuschku.libquassel.util.helpers
import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.WARN
import de.kuschku.libquassel.util.compatibility.log
fun ByteArray.hexDump() {
for (i in 0 until this.size step 33) {
log(WARN, "HexDump",
(0 until 33).map { it + i }.filter { it < this.size }.joinToString(" ") {
String.format("%02x", this[it])
}
)
}
}
......@@ -15,3 +15,10 @@ fun ByteBuffer?.deserializeString(serializer: StringSerializer) = if (this == nu
} else {
serializer.deserializeAll(this)
}
fun ByteBuffer.hexDump() {
val target = ByteBuffer.allocate(this.capacity())
this.clear()
this.copyTo(target)
target.array().hexDump()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment