Read max of 520 bytes for data fields when parsing filteradd messages

This commit is contained in:
Deirdre Connolly 2019-12-02 19:18:55 -05:00 committed by Deirdre Connolly
parent 1b8b4d0fac
commit 3c26092b01
1 changed files with 6 additions and 2 deletions

View File

@ -607,9 +607,13 @@ impl Codec {
})
}
fn read_filteradd<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
fn read_filteradd<R: Read>(&self, reader: R) -> Result<Message, Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes)?;
// Maximum size of data is 520 bytes.
let mut handle = reader.take(520);
handle.read(&mut bytes)?;
Ok(Message::FilterAdd { data: bytes })
}