Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
goldenduo opened this issue Mar 2, 2025 · 0 comments
Open

Comments

@goldenduo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant