Skip to content

Commit be133b8

Browse files
authored
fix 1 byte long disconnect reason (hyperledger#4150)
Signed-off-by: Stefan <stefan.pingel@consensys.net>
1 parent de91d31 commit be133b8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private Optional<Peer> createPeer(final PeerInfo peerInfo, final ChannelHandlerC
205205
if (remoteAddress == null) {
206206
return Optional.empty();
207207
}
208-
int port = peerInfo.getPort();
208+
final int port = peerInfo.getPort();
209209
return Optional.of(
210210
DefaultPeer.fromEnodeURL(
211211
EnodeURLImpl.builder()

ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/wire/messages/DisconnectMessage.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ public void writeTo(final RLPOutput out) {
8080
}
8181

8282
public static Data readFrom(final RLPInput in) {
83-
in.enterList();
84-
Bytes reasonData = in.readBytes();
85-
in.leaveList();
83+
Bytes reasonData = Bytes.EMPTY;
84+
if (in.nextIsList()) {
85+
in.enterList();
86+
reasonData = in.readBytes();
87+
in.leaveList();
88+
} else if (in.nextSize() == 1) {
89+
reasonData = in.readBytes();
90+
}
8691

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

0 commit comments

Comments
 (0)