mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 17:25:21 +00:00
fix: deserialization issue with routed packets
This commit is contained in:
@@ -368,9 +368,16 @@ object BinaryProtocol {
|
|||||||
var routeCount = 0
|
var routeCount = 0
|
||||||
if (hasRoute) {
|
if (hasRoute) {
|
||||||
// Peek count (1 byte) without consuming buffer for now
|
// Peek count (1 byte) without consuming buffer for now
|
||||||
val mark = buffer.position()
|
// The buffer is currently positioned at the start of SenderID (after fixed header)
|
||||||
if (raw.size >= mark + 1) {
|
// We must skip SenderID and RecipientID (if present) to find the route count
|
||||||
routeCount = raw[mark].toUByte().toInt()
|
val currentPos = buffer.position()
|
||||||
|
var routeOffset = currentPos + SENDER_ID_SIZE
|
||||||
|
if (hasRecipient) {
|
||||||
|
routeOffset += RECIPIENT_ID_SIZE
|
||||||
|
}
|
||||||
|
|
||||||
|
if (raw.size >= routeOffset + 1) {
|
||||||
|
routeCount = raw[routeOffset].toUByte().toInt()
|
||||||
}
|
}
|
||||||
expectedSize += 1 + (routeCount * SENDER_ID_SIZE)
|
expectedSize += 1 + (routeCount * SENDER_ID_SIZE)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user