summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-11-29 10:29:18 +0100
committerJustus Winter <justus@sequoia-pgp.org>2022-01-19 16:20:10 +0100
commit927140c6faed033bb1f8550332491b30ea77fba2 (patch)
treee10836c965287cddfff137e9794bca0115266654
parentdc69108f7c8f5270519eb94bb13c20b9bc6e3c77 (diff)
openpgp: Fix crashes in the cleartext signature parser.
-rw-r--r--openpgp/src/armor.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 0f72181d..49f6ea74 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -1451,14 +1451,14 @@ impl<'a> Reader<'a> {
// First, split off the line ending.
let crlf_line_end = line.ends_with(b"\r\n");
- line = &line[..line.len()
- - if crlf_line_end { 2 } else { 1 }];
+ line = &line[..line.len().saturating_sub(
+ if crlf_line_end { 2 } else { 1 })];
// Now, trim whitespace off the line.
while Some(&b' ') == line.last()
|| Some(&b'\t') == line.last()
{
- line = &line[..line.len() - 1];
+ line = &line[..line.len().saturating_sub(1)];
}
text.extend_from_slice(line);