Skip to content

Commit eda13bf

Browse files
committed
Disconnect peer if act message is too short.
1 parent 2df93ca commit eda13bf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,13 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
485485
read_from_conduit_buffer = false;
486486

487487
if let &mut PeerState::Authenticating(ref mut handshake) = &mut peer.encryptor {
488-
let (next_act, conduit) = handshake.process_act(&peer.pending_read_buffer).unwrap();
488+
let (next_act, conduit) = match handshake.process_act(&peer.pending_read_buffer) {
489+
Ok(act_result) => act_result,
490+
Err(e) => {
491+
log_trace!(self, "Invalid act message; disconnecting: {}", e);
492+
return Err(PeerHandleError{ no_connection_possible: false });
493+
}
494+
};
489495
peer.pending_read_buffer = Vec::new(); // empty the pending read buffer
490496

491497
if let Some(key) = handshake.get_remote_pubkey() {

0 commit comments

Comments
 (0)