summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openpgp/src/armor.rs12
-rw-r--r--openpgp/src/parse.rs11
2 files changed, 17 insertions, 6 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index fb6ac87b..ed19c63a 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -1534,12 +1534,6 @@ impl<'a> Reader<'a> {
self.cursor,
self.buffer.as_ref().map(|buffer| buffer.len()));
- // See if there is an error from the last invocation.
- if let Some(e) = self.error.take() {
- t!("Returning stashed error: {}", e);
- return Err(e);
- }
-
if let Some(ref buffer) = self.buffer {
// We have a buffer. Make sure `cursor` is sane.
assert!(self.cursor <= buffer.len());
@@ -1575,6 +1569,12 @@ impl<'a> Reader<'a> {
break;
}
+ // See if there is an error from the last invocation.
+ if let Some(e) = &self.error {
+ t!("We have a stashed error, don't poll again: {}", e);
+ break;
+ }
+
match self.do_read(&mut buffer_new
[amount_buffered + amount_read..]) {
Ok(read) => {
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index d414cbe4..2dc9fad5 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -6491,4 +6491,15 @@ zXvj
-----END PGP SIGNATURE-----
");
}
+
+ /// Tests issue 957.
+ #[test]
+ fn panic_on_malformed_armor() {
+ parse_message("-----BEGIN PGP MESSAGE-----
+
+heLBX8Pq0kUBwQz2iFAzRwOdgTBvH5KsDU9lmE
+
+-----END PGP MESSAGE-----
+");
+ }
}