Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rlp] BasicEncoder produces incorrect results for iterators that are incorrect with their size hints #605

Open
skylerqpq opened this issue Nov 30, 2021 · 0 comments

Comments

@skylerqpq
Copy link

An example of such an iterator:

struct MaliciousIterator<'a> {
    bytes: &'a [u8],
}

impl<'a> Iterator for MaliciousIterator<'a> {
    type Item = u8;
    fn size_hint(&self) -> (usize, Option<usize>) {
        (20, Some(20))
    }

    fn next(&mut self) -> Option<Self::Item> {
        match self.bytes.split_first() {
            Some((first, rest)) => {
                self.bytes = rest;
                Some(*first)
            }
            None => None,
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant