From 962863cbc443d3316fcbc6c043498ecd0bf51d3e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 31 Mar 2025 09:58:35 +1000 Subject: [PATCH] scanner: ensure 'since' doesn't exceed the interface version See https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/327 Part-of: --- proto/ei-scanner | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/proto/ei-scanner b/proto/ei-scanner index af30558..5469934 100755 --- a/proto/ei-scanner +++ b/proto/ei-scanner @@ -565,6 +565,11 @@ class ProtocolParser(xml.sax.handler.ContentHandler): f"Missing attribute {e} in element '{element}'", self.location, ) + if since > self.current_interface.version: + raise XmlError.create( + f"Invalid 'since' {since} for '{self.current_interface.name}.{name}'", + self.location, + ) try: is_bitfield = { @@ -618,6 +623,12 @@ class ProtocolParser(xml.sax.handler.ContentHandler): f"Missing attribute {e} in element '{element}'", self.location, ) + if since > self.current_interface.version: + raise XmlError.create( + f"Invalid 'since' {since} for '{self.current_interface.name}.{name}'", + self.location, + ) + is_destructor = attrs.get("type", "") == "destructor" opcode = len(self.current_interface.requests) request = Request.create( @@ -652,6 +663,11 @@ class ProtocolParser(xml.sax.handler.ContentHandler): f"Missing attribute {e} in element '{element}'", self.location, ) + if since > self.current_interface.version: + raise XmlError.create( + f"Invalid 'since' {since} for '{self.current_interface.name}.{name}'", + self.location, + ) is_destructor = attrs.get("type", "") == "destructor" opcode = len(self.current_interface.events)