Don't panic in import_block if invalid rlp (#8522)
* Don't panic in import_block if invalid rlp * Remove redundant type annotation * Replace RLP header view usage with safe decoding Using the view will panic with invalid RLP. Here we use Rlp decoding directly which will return a `Result<_, DecoderError>`. While this path currently should not have any invalid RLP - it makes it safer if ever called with invalid RLP from other code paths.
This commit is contained in:
committed by
Marek Kotewicz
parent
eec7364760
commit
66c0638f3b
@@ -190,6 +190,7 @@ error_chain! {
|
||||
|
||||
foreign_links {
|
||||
Block(BlockError) #[doc = "Block error"];
|
||||
Decoder(::rlp::DecoderError) #[doc = "Rlp decoding error"];
|
||||
}
|
||||
|
||||
errors {
|
||||
@@ -206,6 +207,7 @@ impl From<Error> for BlockImportError {
|
||||
match e {
|
||||
Error(ErrorKind::Block(block_error), _) => BlockImportErrorKind::Block(block_error).into(),
|
||||
Error(ErrorKind::Import(import_error), _) => BlockImportErrorKind::Import(import_error.into()).into(),
|
||||
Error(ErrorKind::Util(util_error::ErrorKind::Decoder(decoder_err)), _) => BlockImportErrorKind::Decoder(decoder_err).into(),
|
||||
_ => BlockImportErrorKind::Other(format!("other block import error: {:?}", e)).into(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user