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

GOAWAY deserialization fix #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/protocol/framer.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,8 @@ typeSpecificAttributes.GOAWAY = ['last_stream', 'error'];
// +-+-------------------------------------------------------------+
// | Error Code (32) |
// +---------------------------------------------------------------+
// | Additional Debug Data (*) |
// +---------------------------------------------------------------+
//
// The last stream identifier in the GOAWAY frame contains the highest numbered stream identifier
// for which the sender of the GOAWAY frame has received frames on and might have taken some action
Expand All @@ -759,8 +761,8 @@ Serializer.GOAWAY = function writeGoaway(frame, buffers) {
};

Deserializer.GOAWAY = function readGoaway(buffer, frame) {
if (buffer.length !== 8) {
// GOAWAY must have 8 bytes
if (buffer.length < 8) {
// GOAWAY must have at least 8 bytes
return 'FRAME_SIZE_ERROR';
}
frame.last_stream = buffer.readUInt32BE(0) & 0x7fffffff;
Expand All @@ -769,6 +771,12 @@ Deserializer.GOAWAY = function readGoaway(buffer, frame) {
// Unknown error types are to be considered equivalent to INTERNAL ERROR
frame.error = 'INTERNAL_ERROR';
}
// Read remaining data into "debug_data"
// https://http2.github.io/http2-spec/#GOAWAY
// Endpoints MAY append opaque data to the payload of any GOAWAY frame
if (buffer.length > 8) {
frame.debug_data = buffer.slice(8);
}
};

// [WINDOW_UPDATE](https://tools.ietf.org/html/rfc7540#section-6.9)
Expand Down