Skip to content

Commit

Permalink
fix 1 byte long disconnect reason (hyperledger#4150)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan <stefan.pingel@consensys.net>
  • Loading branch information
pinges authored Jul 22, 2022
1 parent de91d31 commit be133b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private Optional<Peer> createPeer(final PeerInfo peerInfo, final ChannelHandlerC
if (remoteAddress == null) {
return Optional.empty();
}
int port = peerInfo.getPort();
final int port = peerInfo.getPort();
return Optional.of(
DefaultPeer.fromEnodeURL(
EnodeURLImpl.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ public void writeTo(final RLPOutput out) {
}

public static Data readFrom(final RLPInput in) {
in.enterList();
Bytes reasonData = in.readBytes();
in.leaveList();
Bytes reasonData = Bytes.EMPTY;
if (in.nextIsList()) {
in.enterList();
reasonData = in.readBytes();
in.leaveList();
} else if (in.nextSize() == 1) {
reasonData = in.readBytes();
}

// Disconnect reason should be at most 1 byte, otherwise, just return UNKNOWN
final DisconnectReason reason =
Expand Down

0 comments on commit be133b8

Please sign in to comment.