From c96838d54d73d4e5e3ea7397e5a7b3100a33e83e Mon Sep 17 00:00:00 2001 From: Alexey Miroshkin Date: Fri, 16 Mar 2018 23:20:40 +0100 Subject: [PATCH] Improve bounding block timestamp (#793) Fixes #783. * 2^60 still fails on OSX, experimentally found safe max 2^55 * Handle negative values I tried to use .abs(), unfortuantely fuzz test kills it with `panicked at 'attempt to negate with overflow', /Users/travis/build/rust-lang/rust/src/libcore/num/mod.rs:1146:17` --- core/src/core/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/core/block.rs b/core/src/core/block.rs index db68e990a..16757af61 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -169,7 +169,7 @@ impl Readable for BlockHeader { let nonce = reader.read_u64()?; let pow = Proof::read(reader)?; - if timestamp > (1 << 60) { + if timestamp > (1 << 55) || timestamp < -(1 << 55) { return Err(ser::Error::CorruptedData); }