Skip to content

Update MaxMessageLength behavior - #32

Open
ltpquang wants to merge 4 commits into
zach-klippenstein:masterfrom
ltpquang:master
Open

Update MaxMessageLength behavior#32
ltpquang wants to merge 4 commits into
zach-klippenstein:masterfrom
ltpquang:master

Conversation

@ltpquang

Copy link
Copy Markdown
Contributor

This PR intends to update goadb's behaviors regarding to message length. So that:

  • Accept all message lengths returned from adb server
  • Update MaxMessageLength and length-checking logics to reflect current adb's implementation

This fixed #31, and (hopefully) #26 #29.

Please take a look @zach-klippenstein. Thanks!

@ltpquang

ltpquang commented Dec 6, 2020

Copy link
Copy Markdown
Contributor Author

@zach-klippenstein hi there any progress on this?

Comment thread wire/conn.go Outdated
// The official implementation of adb imposes an undocumented 255-byte limit
// on messages.
MaxMessageLength = 255
MaxMessageLength = 1024 * 1024

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the above comment, there should also be an explanation where this number comes from.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I've just updated the comment. Also, I renamed MaxMessageLength to MaxPayloadSize for better reflecting adb's implementation.

Comment thread wire/sender.go Outdated

func (s *realSender) SendMessage(msg []byte) error {
if len(msg) > MaxMessageLength {
if len(msg) > MaxMessageLength - 4 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -4?

@ltpquang ltpquang Dec 8, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A message's payload is combined from:

  1. 4-byte hex string denoting message's length
  2. The message itself

The ADB's implementation implies that the MaxPayloadSize is the size of the message AND the length-string:

MaxPayloadSize = MessageLenghtStringSize + MaxMessageLength

Therefore we need to minus 4 bytes (length-string) to get the message's size.

@ltpquang

Copy link
Copy Markdown
Contributor Author

Hi @zach-klippenstein any update on this PR?

@evrins

evrins commented Feb 21, 2021

Copy link
Copy Markdown

please merge this pr.
the limit of 255 bytes on response body size may make ListDevices function panic on parseKeyVal.
because response may trunk making parse fail.
eg:
full response:

24bc6ecc               device product:T782H_EEA model:T782H device:Boston transport_id:8
62bf3267               device product:T782H_EEA model:T782H device:Boston transport_id:7
99384216               device product:T782H_EEA model:T782H device:Boston transport_id:5
abef8bde               device product:T782H_EEA model:T782H device:Boston transport_id:6
f7241975               device product:T782H_EEA model:T782H device:Boston transport_id:4

trunked response:

24bc6ecc               device product:T782H_EEA model:T782H device:Boston transport_id:8
62bf3267               device product:T782H_EEA model:T782H device:Boston transport_id:7
99384216               device product:T782H_EEA model:T782H device:Boston tra

parseKeyVal panic on tra

@webninjadk

Copy link
Copy Markdown

still is not merged?

@aac3476

aac3476 commented May 22, 2024

Copy link
Copy Markdown

why not merged?
if we have too many device it will panic

@asjdf

asjdf commented Aug 12, 2024

Copy link
Copy Markdown

Looking forward to this PR being merged

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

Successfully merging this pull request may close these issues.

Mismatch number of devices returned from goadb

6 participants