summaryrefslogtreecommitdiffstats
path: root/openpgp/src/lib.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-04-27 13:46:53 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-04-28 11:44:43 +0200
commit026eb8345ccfb1a5d248b9514b130b11d9f50e7d (patch)
treee712e3f42648425cc09841278d304bb00e78ab32 /openpgp/src/lib.rs
parent5fce65e4a8273b32c0986d9e805b0128e7478bd2 (diff)
openpgp: Don't generate arbitrarily large S2K parameters.
- We have to stay well below 255 bytes so that packets including the S2K objects are representable.
Diffstat (limited to 'openpgp/src/lib.rs')
-rw-r--r--openpgp/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index 38d2b9e4..a949403a 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -381,4 +381,14 @@ mod arbitrary_helper {
{
s.iter_mut().for_each(|p| *p = Arbitrary::arbitrary(g));
}
+
+ pub(crate) fn arbitrary_bounded_vec<T>(g: &mut Gen, limit: usize) -> Vec<T>
+ where
+ T: Arbitrary + Default,
+ {
+ let mut v = vec![Default::default();
+ gen_arbitrary_from_range(0..limit, g)];
+ arbitrary_slice(g, &mut v[..]);
+ v
+ }
}