Don't try to do a base58 checksum if an address is excessively long
This commit is contained in:
parent
dab2f0b6b6
commit
e2403a37fa
|
@ -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
|
// Base 58
|
||||||
let data = try!(base58::from_check(s));
|
let data = try!(base58::from_check(s));
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ pub enum Error {
|
||||||
/// Checksum was not correct (expected, actual)
|
/// Checksum was not correct (expected, actual)
|
||||||
BadChecksum(u32, u32),
|
BadChecksum(u32, u32),
|
||||||
/// The length (in bytes) of the object was not correct
|
/// 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),
|
InvalidLength(usize),
|
||||||
/// Version byte(s) were not recognized
|
/// Version byte(s) were not recognized
|
||||||
InvalidVersion(Vec<u8>),
|
InvalidVersion(Vec<u8>),
|
||||||
|
|
Loading…
Reference in New Issue