tor-cell: Consistent and secure conversion to u16
This commit improves the overflow protection of one call to Vec::write_u16(), by replacing the cast conversion from self.sig.len() with a call to u16::try_from(), like it is already done in the rest of the accompanying function.
This commit is contained in:
parent
b031616b5f
commit
c42a55d515
|
@ -194,7 +194,7 @@ impl msg::Body for EstablishIntro {
|
|||
}
|
||||
|
||||
w.write_all(&self.handshake_auth[..]);
|
||||
w.write_u16(self.sig.len() as u16);
|
||||
w.write_u16(u16::try_from(self.sig.len()).map_err(|_| EncodeError::BadLengthValue)?);
|
||||
w.write_all(&self.sig[..]);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue