Don't panic on packet data (#6769)
This commit is contained in:
parent
29f3b198cf
commit
65de227520
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -179,8 +179,8 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for ShortVec<T> {
|
|||
/// Return the decoded value and how many bytes it consumed.
|
||||
pub fn decode_len(bytes: &[u8]) -> Result<(usize, usize), Box<bincode::ErrorKind>> {
|
||||
let short_len: ShortU16 = bincode::deserialize(bytes)?;
|
||||
let num_bytes = bincode::serialized_size(&short_len).unwrap() as usize;
|
||||
Ok((short_len.0 as usize, num_bytes))
|
||||
let num_bytes = bincode::serialized_size(&short_len)?;
|
||||
Ok((short_len.0 as usize, num_bytes as usize))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue