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

FIX partial frames during connect's peek of the info block #201

Merged
merged 1 commit into from
Sep 27, 2021

Conversation

aricart
Copy link
Member

@aricart aricart commented Sep 27, 2021

[fix] extractProtocolMessage, was loosely testing the result from protoLen, which returned -1. In such a case, it was possible to attempt processing a frame that wasn't complete. This only happened during connect.

…toLen, which returned -1. In such a case, it was possible to attempt processing a frame that wasn't complete. This only happened during connect.
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

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

LGTM

}

export function extractProtocolMessage(a: Uint8Array): string {
// protocol messages are ascii, so Uint8Array
const len = protoLen(a);
if (len) {
if (len > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Since you changed from -1 to 0, the test if (len) { would then become valid, but I am ok being explicit here.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeap going to keep it that way - at some point I believe the code returned 0, and then changed (this was used by the protocol parser before. Testing for what we are looking for is always a good thing.

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.

2 participants