summaryrefslogtreecommitdiffstats
path: root/openpgp/src/armor.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-01-23 14:14:52 +0100
committerJustus Winter <justus@sequoia-pgp.org>2023-01-23 14:23:39 +0100
commitd7903cb732c9596658085ee469ecea9afa83b1be (patch)
treef024065d9206da93801f3b23c99761a1189aa85d /openpgp/src/armor.rs
parent6ff63362dad9177cfecad2bd672ff75c60727d0e (diff)
buffered-reader, openpgp: Fix overflow calculating buffer capacities
Diffstat (limited to 'openpgp/src/armor.rs')
-rw-r--r--openpgp/src/armor.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 6a3bb381..c46ce6cc 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -1554,8 +1554,9 @@ impl<'a> Reader<'a> {
// The caller wants more data than we have readily
// available. Read some more.
- let capacity : usize = amount
- + cmp::max(DEFAULT_BUF_SIZE, 2 * self.preferred_chunk_size);
+ let capacity : usize = amount.saturating_add(
+ DEFAULT_BUF_SIZE.max(
+ self.preferred_chunk_size.saturating_mul(2)));
let mut buffer_new = self.unused_buffer.take()
.map(|mut v| {