-
Notifications
You must be signed in to change notification settings - Fork 108
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
Update MaxMessageLength behavior #32
base: master
Are you sure you want to change the base?
Conversation
@zach-klippenstein hi there any progress on this? |
wire/conn.go
Outdated
@@ -5,7 +5,7 @@ import "github.com/zach-klippenstein/goadb/internal/errors" | |||
const ( | |||
// The official implementation of adb imposes an undocumented 255-byte limit | |||
// on messages. | |||
MaxMessageLength = 255 | |||
MaxMessageLength = 1024 * 1024 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
wire/sender.go
Outdated
@@ -29,7 +29,7 @@ func SendMessageString(s Sender, msg string) error { | |||
} | |||
|
|||
func (s *realSender) SendMessage(msg []byte) error { | |||
if len(msg) > MaxMessageLength { | |||
if len(msg) > MaxMessageLength - 4 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why -4?
There was a problem hiding this comment.
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:
- 4-byte hex string denoting message's length
- 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.
Hi @zach-klippenstein any update on this PR? |
please merge this pr.
trunked response:
|
still is not merged? |
why not merged? |
Looking forward to this PR being merged |
This PR intends to update
goadb
's behaviors regarding to message length. So that:MaxMessageLength
and length-checking logics to reflect current adb's implementationThis fixed #31, and (hopefully) #26 #29.
Please take a look @zach-klippenstein. Thanks!