diff --git a/src/util/address.rs b/src/util/address.rs index 95cf6e2..80d9660 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -259,6 +259,10 @@ impl FromStr for Address { }); } + if s.len() > 50 { + return Err(Error::Base58(base58::Error::InvalidLength(s.len() * 11 / 15))); + } + // Base 58 let data = try!(base58::from_check(s)); diff --git a/src/util/base58.rs b/src/util/base58.rs index 91badc9..5162edc 100644 --- a/src/util/base58.rs +++ b/src/util/base58.rs @@ -27,6 +27,8 @@ pub enum Error { /// Checksum was not correct (expected, actual) BadChecksum(u32, u32), /// The length (in bytes) of the object was not correct + /// Note that if the length is excessively long the provided length may be + /// an estimate (and the checksum step may be skipped). InvalidLength(usize), /// Version byte(s) were not recognized InvalidVersion(Vec),