spice-common/python_modules
Frediano Ziglio a69fb1ec34 Fix integer overflows computing sizes
Make code safe using both 32 and 64 bit machine.
Consider that this code can be compiled for machines with 32 bit.
There are some arrays length which are 32 bit.

If size_t this can cause easily an overflow. For instance message_len
sending SPICE_MSG_NOTIFY messages are 32 bit and code add a small
constant (currently 24) before doing the test for size. Now passing
(uint32_t) -20 as message_len would lead to a size of 4 after the
addition. This overflow does not happen on 64 bit machine as the length
is converted to size_t.

There are also some array length where some item are bigger than 1 byte.
For instance SPICE_MAIN_CHANNELS_LIST message have a number of channels
and each channel is composed by 2 bytes. Now the code generated try to do
length * 2 where length is still a 32 bit so if we put a value like
0x80000002u we get 4 as length. This will cause an overflow as code will
allocate very few bytes but try to fill with a huge number of elements.
This overflow happen in both 32 and 64 bit machine.

To avoid all these possible overflows this patch use only 64 bit for
nelements (number of elements), nw_size (network size) and mem_size
(memory size needed) checking the sizes to avoid other overflows
(like pointers conversions under 32 bit machines).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2018-05-11 08:41:36 +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 integer overflows computing sizes 2018-05-11 08:41:36 +01:00
Makefile.am Revert "Remove files moved to spice-protocol" 2016-03-10 16:01:36 +01:00
marshal.py codegen: Fix compatibility with Python 2.6 2016-07-30 08:57:05 +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