fix(pdu): overflow when decoding RsaPublicKey (#409)

This commit is contained in:
Norbert Szetei
2024-03-11 09:46:01 -04:00
committed by GitHub
parent c4193371bd
commit 7e11d3e198
3 changed files with 6 additions and 0 deletions
@@ -217,6 +217,8 @@ pub enum ServerLicenseError {
InvalidRsaPublicKeyLength,
#[error("invalid RSA public key data length")]
InvalidRsaPublicKeyDataLength,
#[error("invalid RSA public key bit length")]
InvalidRsaPublicKeyBitLength,
#[error("invalid License Header security flags")]
InvalidSecurityFlags,
#[error("the server returned unexpected error: {0:?}")]
@@ -160,6 +160,10 @@ impl PduParsing for RsaPublicKey {
return Err(ServerLicenseError::InvalidRsaPublicKeyLength);
}
if bitlen < 8 {
return Err(ServerLicenseError::InvalidRsaPublicKeyBitLength);
}
let datalen = stream.read_u32::<LittleEndian>()?;
if datalen != (bitlen / 8) - 1 {
return Err(ServerLicenseError::InvalidRsaPublicKeyDataLength);