diff --git a/core/src/core/block.rs b/core/src/core/block.rs index 92c04d2a8..ae62dca34 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -18,6 +18,7 @@ use rand::{thread_rng, Rng}; use std::collections::HashSet; use std::fmt; use std::iter::FromIterator; +use chrono::naive::{MAX_DATE, MIN_DATE}; use chrono::prelude::{DateTime, NaiveDateTime, Utc}; use consensus::{self, exceeds_weight, reward, VerifySortOrder, REWARD}; @@ -190,7 +191,7 @@ impl Readable for BlockHeader { ser_multiread!(reader, read_u64, read_u64, read_u64); let pow = Proof::read(reader)?; - if timestamp > (1 << 55) || timestamp < -(1 << 55) { + if timestamp > MAX_DATE.and_hms(0,0,0).timestamp() || timestamp Result { let cuckoo_sizeshift = reader.read_u8()?; + if cuckoo_sizeshift == 0 || cuckoo_sizeshift > 64 { + return Err(Error::CorruptedData); + } let mut nonces = Vec::with_capacity(global::proofsize()); let nonce_bits = cuckoo_sizeshift as usize - 1;