Don't panic on packet data (#6769)

This commit is contained in:
Jack May
2019-11-06 14:32:37 -08:00
committed by GitHub
parent 29f3b198cf
commit 65de227520
4 changed files with 10 additions and 9 deletions

View File

@ -973,10 +973,13 @@ impl Archiver {
socket.send_to(&serialized_req, to).unwrap();
let mut buf = [0; 1024];
if let Ok((size, _addr)) = socket.recv_from(&mut buf) {
return bincode::config()
// Ignore bad packet and try again
if let Ok(slot) = bincode::config()
.limit(PACKET_DATA_SIZE as u64)
.deserialize(&buf[..size])
.unwrap();
{
return slot;
}
}
sleep(Duration::from_millis(500));
}

View File

@ -1183,8 +1183,8 @@ impl ClusterInfo {
"cluster_info-gossip_pull_request_verify_fail",
1
);
} else if caller.contact_info().is_some() {
if caller.contact_info().unwrap().id == me.read().unwrap().gossip.id {
} else if let Some(contact_info) = caller.contact_info() {
if contact_info.id == me.read().unwrap().gossip.id {
warn!("PullRequest ignored, I'm talking to myself");
inc_new_counter_debug!("cluster_info-window-request-loopback", 1);
} else {

View File

@ -43,9 +43,7 @@ impl ShredSigVerifier {
let slot_end = slot_start + size_of::<u64>();
trace!("slot {} {}", slot_start, slot_end,);
if slot_end <= packet.meta.size {
let slot: u64 =
limited_deserialize(&packet.data[slot_start..slot_end]).ok()?;
Some(slot)
limited_deserialize(&packet.data[slot_start..slot_end]).ok()
} else {
None
}