summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-21 16:35:30 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:03 +0300
commit75b5b3fbbf8c33d10fd30e21f645b8ef1513363a (patch)
tree733b695659c128cae980c8ebbdc05966038e5707 /openpgp
parent795b89ae024d3d49a6f08283184b22770e160317 (diff)
Improve error message for a malformed packet
Suggested by Neal Walfield. Found by clippy lint useless_format: https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/packet/pkesk.rs5
-rw-r--r--openpgp/src/parse.rs4
2 files changed, 5 insertions, 4 deletions
diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs
index 40e7bc37..50ec187a 100644
--- a/openpgp/src/packet/pkesk.rs
+++ b/openpgp/src/packet/pkesk.rs
@@ -161,7 +161,8 @@ impl PKESK3 {
if key_rgn.len() != sym_algo.key_size()? {
return Err(Error::MalformedPacket(
- format!("session key has the wrong size")).into());
+ format!("session key has the wrong size (got: {}, expected: {})",
+ key_rgn.len(), sym_algo.key_size()?)).into())
}
key.copy_from_slice(&plain[key_rgn]);
@@ -174,7 +175,7 @@ impl PKESK3 {
if their_checksum == our_checksum {
Ok((sym_algo, key))
} else {
- Err(Error::MalformedPacket(format!("key checksum wrong"))
+ Err(Error::MalformedPacket("key checksum wrong".to_string())
.into())
}
}
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 549b94f2..eacded35 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -5185,11 +5185,11 @@ impl<'a> PacketParser<'a> {
if self.content_was_read {
return Err(Error::InvalidOperation(
- format!("Packet's content has already been read.")).into());
+ "Packet's content has already been read.".to_string()).into());
}
if ! self.encrypted {
return Err(Error::InvalidOperation(
- format!("Packet not encrypted.")).into());
+ "Packet not encrypted.".to_string()).into());
}
if algo.key_size()? != key.len () {