diff options
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 |