Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Fixed issue that crashed Mesh node #888

Merged
merged 6 commits into from
Jul 28, 2020
Merged
Changes from 1 commit
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
Next Next commit
Fixed issue that crashed Mesh node
  • Loading branch information
jalextowle committed Jul 28, 2020
commit 7a6f0d477e01f285f8b29b2953ddba031880d592
13 changes: 12 additions & 1 deletion core/ordersync/ordersync.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,19 @@ func (s *Service) HandleStream(stream network.Stream) {
if len(rawReq.Subprotocols) > 1 {
firstRequests := FirstRequestsForSubprotocols{}
err := json.Unmarshal(rawReq.Metadata, &firstRequests)
if err == nil {

// NOTE(jalextowle): Older versions of Mesh did not include
// metadata in the first ordersync request. Ensure that
// the array is long enough before accessing it to avoid
// crashing the node.
if err == nil && len(firstRequests.MetadataForSubprotocol) > i {
rawReq.Metadata = firstRequests.MetadataForSubprotocol[i]
} else {
log.WithFields(log.Fields{
jalextowle marked this conversation as resolved.
Show resolved Hide resolved
"subprotocols": rawReq.Subprotocols,
"metadataForSubprotocol": firstRequests.MetadataForSubprotocol,
"error": err.Error(),
}).Debug("unable to decode first request metadata")
}
}
res, err := handleRequestWithSubprotocol(s.ctx, subprotocol, requesterID, rawReq)
Expand Down