Merge branch 'assert_maxlen' into 'main'

tor-cell: Assert data length in Data cells

See merge request tpo/core/arti!800
This commit is contained in:
Nick Mathewson 2022-10-27 01:46:21 +00:00
commit 9f73ddd440
1 changed files with 2 additions and 1 deletions

View File

@ -400,8 +400,9 @@ impl Data {
/// Construct a new data cell from a provided vector of bytes.
///
/// The vector _must_ have fewer than [`Data::MAXLEN`] bytes.
/// The vector _must_ not have more than [`Data::MAXLEN`] bytes.
fn new_unchecked(body: Vec<u8>) -> Self {
debug_assert!(body.len() <= Data::MAXLEN);
Data { body }
}
}