Cdm: Validate License Message type in parse_license

This commit is contained in:
rlaphoenix 2022-07-24 21:07:00 +01:00
parent b081d66ca2
commit ac469383b8
1 changed files with 6 additions and 0 deletions

View File

@ -211,6 +211,12 @@ class Cdm:
if not isinstance(license_message, SignedMessage): if not isinstance(license_message, SignedMessage):
raise ValueError(f"Expecting license_response to be a SignedMessage, got {license_message!r}") raise ValueError(f"Expecting license_response to be a SignedMessage, got {license_message!r}")
if license_message.type != SignedMessage.MessageType.LICENSE:
raise ValueError(
f"Expecting a LICENSE message, not a "
f"'{SignedMessage.MessageType.Name(license_message.type)}' message."
)
licence = License() licence = License()
licence.ParseFromString(license_message.msg) licence.ParseFromString(license_message.msg)