spice-common/python_modules
Eduardo Lima (Etrunko) 20bda4dba9 Fix demarshaller code generator
Even though commit df4ec5c318 commented
out most of smartcard code which triggered this error, it still might
happen if a new message is added with an array member.

The reason is a missing declaration of mem_size, which is fixed simply
by checking if the attribute 'nocopy' is present.

The error log follows:

generated_server_demarshallers.c: In function ‘parse_msgc_smartcard_reader_add’:
generated_server_demarshallers.c:1985:30: error: ‘mem_size’ undeclared (first use in this function); did you mean ‘nw_size’?
     data = (uint8_t *)malloc(mem_size);
                              ^~~~~~~~
                              nw_size

This patch also updates test-marshallers so that this bug is triggered.

The diff between generated demarshallers with the patch applied follows:

--- tests/generated_test_demarshallers.c.old    2018-05-17 14:35:29.234056487 -0300
+++ tests/generated_test_demarshallers.c        2018-05-17 14:35:40.554031295 -0300
@@ -286,6 +286,7 @@ static uint8_t * parse_msg_main_ArrayMes
     uint8_t *start = message_start;
     uint8_t *data = NULL;
     uint64_t nw_size;
+    uint64_t mem_size;
     uint8_t *in, *end;
     uint64_t name__nw_size;
     uint64_t name__nelements;
@@ -298,6 +299,7 @@ static uint8_t * parse_msg_main_ArrayMes
     }

     nw_size = 0 + name__nw_size;
+    mem_size = sizeof(SpiceMsgMainArrayMessage);

     /* Check if message fits in reported side */
     if (nw_size > (uintptr_t) (message_end - start)) {

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-17 21:02:58 +01:00
..
__init__.py Revert "Remove files moved to spice-protocol" 2016-03-10 16:01:36 +01:00
codegen.py Revert "Remove files moved to spice-protocol" 2016-03-10 16:01:36 +01:00
demarshal.py Fix demarshaller code generator 2018-05-17 21:02:58 +01:00
Makefile.am Revert "Remove files moved to spice-protocol" 2016-03-10 16:01:36 +01:00
marshal.py Avoid integer overflow computing image sizes 2018-05-11 17:00:26 +01:00
ptypes.py codegen: Removed unused get_type methods 2018-05-09 11:59:33 +01:00
spice_parser.py protocol: learn to describe fd passing in messages 2016-03-10 16:01:42 +01:00