Skip to content

Commit ec4f908

Browse files
Calimero92RamseyTI
authored andcommitted
Mismatch between C++ and Python for callback index type
In eRPC, when multiple callbacks are defined, callbacks are stored in an array on both the client and server. When a callback is register, only the index of the callback in this array is sent over the transport. In C++, the array index is encoded as a unit8, where as in Python it is encoded as a uint32. So, a Python client will not be aligned with a C++ server, leading to wrong information being decoded by the server. This fix aligns both to be a uint8 type for the callback index.
1 parent 7940147 commit ec4f908

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

erpcgen/src/templates/py_coders.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ codec.start_write_union({$self}discriminator)
8080
{#--------------- function ---------------#}
8181
{% elif info.type == "function" %}
8282
{% if info.tableName != "" %}
83-
{$codec}.write_int32({$ info.tableName}.index({$name})){%>%}
83+
{$codec}.write_int8({$ info.tableName}.index({$name})){%>%}
8484
{% else %}
8585
# When are defined less than 2 callback functions, eRPC don't need serialize any code.
8686
{% endif%}
@@ -171,7 +171,7 @@ _n{$depth} = {$codec}.start_read_list()
171171
{#--------------- function ---------------#}
172172
{% elif info.type == "function" %}
173173
{% if info.tableName != "" %}
174-
{$name} = {$ info.tableName}[{$codec}.read_int32()]
174+
{$name} = {$ info.tableName}[{$codec}.read_int8()]
175175
{% else %}
176176
# When are defined less than 2 callback functions, eRPC don't need serialize any code.
177177
{$indent}{$name} = {$info.callbackName}

0 commit comments

Comments
 (0)