Go to file
Frediano Ziglio 62b44b3073 proto: Demarshal Smartcard data field
Currently the demarshaler code is not used by spice-server.
Demarshal all the fields of the header message, not only the header.
Using generated code allows to easily check data and support
big endian machines. Generated code will be used by spice-server.

The resulting change is.

   diff -ru gen/generated_client_marshallers.c common/generated_client_marshallers.c
    --- gen/generated_client_marshallers.c      2019-10-05 20:44:54.000000000 +0100
    +++ common/generated_client_marshallers.c   2019-10-05 20:45:33.000000000 +0100
    @@ -283,6 +283,7 @@
         spice_marshaller_add_uint32(m, src->type);
         spice_marshaller_add_uint32(m, src->reader_id);
         spice_marshaller_add_uint32(m, src->length);
    +    /* Don't marshall @nomarshal data */
     }

     #endif /* USE_SMARTCARD */
    diff -ru gen/generated_server_demarshallers.c common/generated_server_demarshallers.c
    --- gen/generated_server_demarshallers.c    2019-10-05 20:44:54.000000000 +0100
    +++ common/generated_server_demarshallers.c 2019-10-05 20:45:33.000000000 +0100
    @@ -1451,10 +1451,25 @@
         uint64_t nw_size;
         uint64_t mem_size;
         uint8_t *in, *end;
    +    uint64_t data__nw_size, data__mem_size;
    +    uint64_t data__nelements;
         VSCMsgHeader *out;

    -    nw_size = 12;
    -    mem_size = sizeof(VSCMsgHeader);
    +    { /* data */
    +        uint32_t length__value;
    +        pos = start + 8;
    +        if (SPICE_UNLIKELY(pos + 4 > message_end)) {
    +            goto error;
    +        }
    +        length__value = read_uint32(pos);
    +        data__nelements = length__value;
    +
    +        data__nw_size = data__nelements;
    +        data__mem_size = sizeof(uint8_t) * data__nelements;
    +    }
    +
    +    nw_size = 12 + data__nw_size;
    +    mem_size = sizeof(VSCMsgHeader) + data__mem_size;

         /* Check if message fits in reported side */
         if (nw_size > (uintptr_t) (message_end - start)) {
    @@ -1474,6 +1489,10 @@
         out->type = consume_uint32(&in);
         out->reader_id = consume_uint32(&in);
         out->length = consume_uint32(&in);
    +    verify(sizeof(out->data) == 0);
    +    memcpy(out->data, in, data__nelements);
    +    in += data__nelements;
    +    end += data__nelements;

         assert(in <= message_end);
         assert(end <= data + mem_size);

The @nomarshal attribute allows to not change the marshaling code
(used by spice-gtk).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-10-08 14:40:32 +01:00
common common/recorder.h: do not complain on unused (dummy) recorders 2019-09-11 10:02:44 +01:00
docs docs: add spice URI scheme 2019-02-21 14:22:18 +00:00
m4 build: Disable Celt support by default 2019-06-13 08:51:11 +01:00
python_modules codegen: Add a check for C structure fields 2019-08-14 15:49:19 +01:00
tests common/recorder.h: do not complain on unused (dummy) recorders 2019-09-11 10:02:44 +01:00
.gitlab-ci.yml ci: Remove dependencies from copr build 2019-03-12 12:43:38 +00:00
.gitmodules Integrate recorder library 2019-01-23 14:44:19 +00:00
.gitpublish Add a .gitpublish 2019-01-15 17:35:51 +04:00
autogen.sh Remove files moved to spice-protocol 2015-08-11 10:26:06 +02:00
configure.ac build: Add new check for recorder library 2019-04-03 09:32:46 +01:00
COPYING Remove trailing whitespace 2015-12-18 11:41:15 +01:00
git.mk build: Update git.mk to latest version 2018-06-18 14:08:03 +01:00
Makefile.am proto: Remove support for SPICE version 1 2018-09-28 09:00:03 +01:00
meson_options.txt build: Disable Celt support by default 2019-06-13 08:51:11 +01:00
meson.build meson: Remove "install" argument from configure_file 2019-08-29 04:51:48 +01:00
spice_codegen.py codegen: Exit with error on error generating C structures 2019-08-13 18:11:04 +01:00
spice.proto proto: Demarshal Smartcard data field 2019-10-08 14:40:32 +01:00