mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 05:28:02 +02:00
protocol: check any incoming/outgoing messages for versions
Don't let a interface version 2 send version 3 request or receive those events.
This commit is contained in:
parent
c98a9fc7d7
commit
b9037ed4ff
1 changed files with 8 additions and 0 deletions
|
|
@ -75,6 +75,10 @@ int
|
|||
{
|
||||
const struct brei_object *obj = {{interface.name}}_get_proto_object({{interface.name}});
|
||||
{{target.ctype}} ctx = {{interface.name}}_get_{{target.context}}({{interface.name}});
|
||||
|
||||
if (obj->version < {{outgoing.fqdn.upper()}}_SINCE_VERSION)
|
||||
return -ENOTSUP;
|
||||
|
||||
return {{target.name}}_send_message(
|
||||
ctx, obj->id, {{outgoing.fqdn.upper()}}, "{{outgoing.signature}}",
|
||||
{{outgoing.arguments|length}}{%- for arg in outgoing.arguments %}, {{arg.name}}{% endfor -%}
|
||||
|
|
@ -96,9 +100,13 @@ static int
|
|||
) {
|
||||
{% if interface.incoming|length %}
|
||||
const struct {{interface.name}}_interface *interface = {{interface.name}}_get_interface({{interface.name}});
|
||||
const struct brei_object *obj = {{interface.name}}_get_proto_object({{interface.name}});
|
||||
|
||||
switch (opcode) {
|
||||
{% for incoming in interface.incoming %}
|
||||
case {{incoming.fqdn.upper()}}:
|
||||
if (obj->version < {{incoming.fqdn.upper()}}_SINCE_VERSION)
|
||||
return -ENOTSUP;
|
||||
assert(interface->{{incoming.name}} != NULL);
|
||||
return interface->{{incoming.name}}({{interface.name}}{% for arg in incoming.arguments %}, (args + {{loop.index - 1}})->{{arg.argtype}}{% endfor %});
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue