From ac469383b85f9501da15ba441bca0988c2d775d2 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 24 Jul 2022 21:07:00 +0100 Subject: [PATCH] Cdm: Validate License Message type in parse_license --- pywidevine/cdm.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pywidevine/cdm.py b/pywidevine/cdm.py index 40cae91..29943fc 100644 --- a/pywidevine/cdm.py +++ b/pywidevine/cdm.py @@ -211,6 +211,12 @@ class Cdm: if not isinstance(license_message, SignedMessage): 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.ParseFromString(license_message.msg)