scanner: ensure 'since' doesn't exceed the interface version

See https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/327

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/328>
This commit is contained in:
Peter Hutterer 2025-03-31 09:58:35 +10:00
parent b0deafc641
commit 962863cbc4

View file

@ -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)