Skip to content

throw RequestRejectedException("Unexpected string length: $length") #120

@goldenduo

Description

@goldenduo
suspend fun Socket.readProtocolString(): String {
    withMaxPacketBuffer {
        val transformer = StringResponseTransformer()
        val copied = copyTo(transformer, this, limit = 4L)
        val length = transformer.transform()
        if (copied != 4L) {
            throw RequestRejectedException("Unexpected string length: $length")
        }
        val messageLength = length.toIntOrNull(16) ?: throw RequestRejectedException("Unexpected string length: $length")

        compatClear()
        compatLimit(messageLength)
        val read = readFully(this)
        if (read != messageLength) throw RequestRejectedException("Incomplete string received")
        return String(array(), 0, read, Const.DEFAULT_TRANSPORT_ENCODING)
    }
}

copied equals 0 when there is no device connected in the following env.
Android Debug Bridge version 1.0.41
Version 35.0.2-12147458
Running on Windows 10.0.19045

This is not a exception but it throws RequestRejectedException.

I think adam should declare -1 for copied in this situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions