We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4504f9c commit d69d3c4Copy full SHA for d69d3c4
src/message.rs
@@ -246,7 +246,10 @@ impl<W: Write> WriteMessage for W {
246
}
247
248
// add size of length value
249
- try!(self.write_u32::<BigEndian>(try!(u32::from_usize(buf.len() + mem::size_of::<u32>()))));
+ if buf.len() > u32::max_value() as usize - mem::size_of::<u32>() {
250
+ return Err(io::Error::new(io::ErrorKind::InvalidInput, "value too large to transmit"));
251
+ }
252
+ try!(self.write_u32::<BigEndian>((buf.len() + mem::size_of::<u32>()) as u32));
253
try!(self.write_all(&*buf));
254
255
Ok(())
0 commit comments