diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-09 11:44:23 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-09 16:43:26 +0200 |
commit | 9a826d92176891e76ba24df3b9804424f27afde3 (patch) | |
tree | c14f9e4d6661a10890d38e9b0cb10cd3c8cedc85 /openpgp | |
parent | ce1c73099d98084037247991d8d68694ceb5c0ff (diff) |
openpgp: Rename MAX_RECURSION_DEPTH and make it public.
- Rename to DEFAULT_MAX_RECURSION_DEPTH to better reflect the fact
that it is not a absolute maximum, but only the default. Make it
public so that the documentation can refer to that.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/parse.rs | 15 | ||||
-rw-r--r-- | openpgp/src/parse/packet_parser_builder.rs | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index d38d306c..5d32c7a7 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -18,7 +18,7 @@ //! `recurse()` method or the `next()` method, as appropriate. //! OpenPGP doesn't impose any restrictions on the amount of nesting. //! So, to prevent a denial of service attack, the parsers don't -//! recurse more than `MAX_RECURSION_DEPTH` times, by default. +//! recurse more than `DEFAULT_MAX_RECURSION_DEPTH` times, by default. //! //! Second, packets can contain an effectively unbounded amount of //! data. To avoid errors due to memory exhaustion, the @@ -227,13 +227,16 @@ macro_rules! impl_parse_generic_packet { }; } -/// The default amount of acceptable nesting. Typically, we expect a -/// message to looking like: +/// The default amount of acceptable nesting. /// -/// [ encryption container: [ signature: [ compressioned data: [ literal data ]]]] +/// Typically, we expect a message to looking like: +/// +/// ```text +/// [ encryption container: [ compressioned data: [ signature: [ literal data ]]]] +/// ``` /// /// So, this should be more than enough. -const MAX_RECURSION_DEPTH : u8 = 16; +pub const DEFAULT_MAX_RECURSION_DEPTH : u8 = 16; /// The default maximum size of non-container packets. /// @@ -858,7 +861,7 @@ struct PacketParserSettings { impl Default for PacketParserSettings { fn default() -> Self { PacketParserSettings { - max_recursion_depth: MAX_RECURSION_DEPTH, + max_recursion_depth: DEFAULT_MAX_RECURSION_DEPTH, max_packet_size: MAX_PACKET_SIZE, buffer_unread_content: false, map: false, diff --git a/openpgp/src/parse/packet_parser_builder.rs b/openpgp/src/parse/packet_parser_builder.rs index b9b5ebb3..ce2ec319 100644 --- a/openpgp/src/parse/packet_parser_builder.rs +++ b/openpgp/src/parse/packet_parser_builder.rs @@ -88,8 +88,8 @@ impl<'a> PacketParserBuilder<'a> { /// recurse; it will only parse the top-level packets. /// /// This is a u8, because recursing more than 255 times makes no - /// sense. The default is `MAX_RECURSION_DEPTH`. (GnuPG defaults - /// to a maximum recursion depth of 32.) + /// sense. The default is `DEFAULT_MAX_RECURSION_DEPTH`. (GnuPG + /// defaults to a maximum recursion depth of 32.) pub fn max_recursion_depth(mut self, value: u8) -> Self { self.settings.max_recursion_depth = value; self |