Commit Graph

978 Commits

Author SHA1 Message Date
Frediano Ziglio
d8fe0cbb84 codegen: Remove bytes array length support
This syntax was only used in protocol 1 which has been removed
time ago.
Beside not being used it's confusing and prone to errors,
array size is specified using 2 identifiers, one reporting
bytes and the other number of items, one used for marshalling,
the other for demarshalling.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-10-06 13:09:56 +01:00
Frediano Ziglio
d589542e04 test-quic: Add test cases for quic fuzzer
To use for start for the fuzzer.

Tests have been generated with a patch like:

	diff --git a/tests/test-quic.c b/tests/test-quic.c
	--- a/tests/test-quic.c
	+++ b/tests/test-quic.c
	@@ -372,8 +372,8 @@ static void pixbuf_compare(GdkPixbuf *pixbuf_a, GdkPixbuf *pixbuf_b)
	 static GdkPixbuf *pixbuf_new_random(int alpha)
	 {
	     gboolean has_alpha = alpha >= 0 ? alpha : g_random_boolean();
	-    gint width = g_random_int_range(100, 2000);
	-    gint height = g_random_int_range(100, 500);
	+    gint width = g_random_int_range(10, 100);
	+    gint height = g_random_int_range(10, 100);
	     GdkPixbuf *random_pixbuf;
	     guint i, size;
	     guint8 *pixels;
	@@ -401,6 +401,12 @@ static void test_pixbuf(GdkPixbuf *pixbuf)
	     compressed_data = quic_encode_from_pixbuf(pixbuf, imgbuf);

	     uncompressed_pixbuf = quic_decode_to_pixbuf(compressed_data);
	+    {
	+        static int num = 0;
	+        char fn[256];
	+        sprintf(fn, "test%d.quic", ++num);
	+        g_assert(g_file_set_contents(fn, (void *) compressed_data->data, compressed_data->len, NULL));
	+    }
	     image_buf_free(imgbuf, uncompressed_pixbuf);

	     //g_assert(memcmp(gdk_pixbuf_get_pixels(pixbuf), gdk_pixbuf_get_pixels(uncompressed_pixbuf), gdk_pixbuf_get_byte_length(uncompressed_pixbuf)));

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
3b81e67979 test-quic: Add fuzzer capabilities to the test
Allows it to be used for fuzzying compressed images.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
b24fe6b66b quic: Avoid possible buffer overflow in find_bucket
Proved by fuzzing the code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
ef1b6ff7b8 quic: Check RLE lengths
Avoid buffer overflows decoding images. On compression we compute
lengths till end of line so it won't cause regressions.
Proved by fuzzing the code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
404d74782c quic: Check image size in quic_decode_begin
Avoid some overflow in code due to images too big or
negative numbers.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Frediano Ziglio
762e0abae3 quic: Check we have some data to start decoding quic image
All paths already pass some data to quic_decode_begin but for the
test check it, it's not that expensive test.
Checking for not 0 is enough, all other words will potentially be
read calling more_io_words but we need one to avoid a potential
initial buffer overflow or deferencing an invalid pointer.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-09-17 06:46:57 +01:00
Marc-André Lureau
fa0c199d33 agent: fix vdagent monitor flag filtering
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-09-17 06:46:26 +01:00
Frediano Ziglio
0d7d0d35d8 agent: Extend agent_check_message to support VDAgentMonitorsConfig extension
Add support for VD_AGENT_CONFIG_MONITORS_FLAG_PHYSICAL_SIZE flag.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2020-09-15 11:55:45 +01:00
Frediano Ziglio
b03c894c21 quic: Fix typo in comment
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-09-04 21:05:48 +01:00
Frediano Ziglio
03bde6fdb2 quic: Constify a parameter
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-08-31 12:36:15 +01:00
Frediano Ziglio
243c314b3f proto: Add support for side mouse buttons
This is the couterpart of spice-protocol commit

    commit cbe7b2c28543f4c5e57d1db1b753b73a64104162 (HEAD -> master, origin/master, origin/HEAD)
    Author: SimonP <simonp.git@gmail.com>

        protocol: Add support for side mouse buttons

        Side mouse buttons currently do not exist in the protocol, causing them
        to be inexplicably ignored by VMs in virt-manager and such. This lays
        the groundwork for fixing that issue.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-08-31 12:33:11 +01:00
Frediano Ziglio
c39cc1b1ef ssl_verify: Do not check IP if we fail to resolve it
There's no point on checking an empty IP address, an IP
address is never empty.
This also solve some compiler warnings trying to possibly
pass a NULL pointer to memcmp or setting a variable without
reading it.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-27 18:50:01 +01:00
Frediano Ziglio
7daee890be quic_tmpl: Remove unused bpc parameter
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-25 12:26:20 +01:00
Frediano Ziglio
2f045752d5 helper-fuzzer-demarshallers: Provide replacement for ftello for MSVC
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-10 09:55:31 +01:00
Frediano Ziglio
b843d02a1b Avoid usage of GCC extension for __VA_ARGS__ where possible
The "##" before __VA_ARGS__ is a GCC extension.
Try to limit its usage where necessary.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-10 09:55:27 +01:00
Frediano Ziglio
ca1016eb15 backtrace: Do not attempt to compile if spice_backtrace is empty
In backtrace.h spice_backtrace is defined as:

  #if defined(WIN32) && !defined(__MINGW32__)
  #define spice_backtrace()
  #else
  ..

so don't try to compile if an empty macro is used.
Currently not causing any issue as we use MingW on Windows but
does not hurt is code is more portable.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-08-10 09:55:10 +01:00
Haochen Tong
8e0e13881e marshal: fix clang "missing field initializer" warning on generated files
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-07-11 08:17:20 +01:00
Haochen Tong
bca74fb6c9 pixman_utils: fix clang "unused functions" warning
Signed-off-by: Haochen Tong <i@hexchain.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-07-11 08:17:18 +01:00
Frediano Ziglio
35be203f42 snd_codec: Use better type for snd_codec_create mode
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-07 13:09:38 +01:00
Frediano Ziglio
283d82b0a3 snd_codec: Use better type for function result
Instead of just plain preprocessor macros use an enum.
This is more type safe and could produce better debugging
type information.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-07 13:09:36 +01:00
Frediano Ziglio
8d9a79dd7d snd_codec: Use better types for snd_codec_is_capable
mode should be an enumeration value of SpiceAudioDataMode.
Return type is just a boolean.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-07 13:09:14 +01:00
Frediano Ziglio
a95ba61d32 build: Remove -Werror from Meson build
In Meson better to use --werror option instead to manually add to
options.
Also this prevents build if spice-protocol deprecate some stuff
or fails the build if any warning occur.
This fixes an issue for
https://gitlab.freedesktop.org/spice/spice/-/issues/44.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-03 10:42:14 +01:00
Frediano Ziglio
ba7af04f65 rect: Avoid usage of "small"
Some Windows headers define "small" causing issues.
Use "small_rect" instead. For coherence use "big_rect" instead of
"big".

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-06-25 16:17:39 +01:00
Frediano Ziglio
5d8feeb19a Reuse macros from spice-protocol
Reuse SPICE_GNUC_NORETURN and SPICE_GNUC_PRINTF

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-19 14:45:36 +01:00
Frediano Ziglio
a5ee3cbac5 test-quic: Different "more_space" function for decode and encode
The "more_space" callback is used in both decode and encode path to provide
either more space to read or more space to write.
The current implementation was dealing only to provide more space to write
(that is encoding) crashing in case it was used for decoding.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-05-23 10:48:28 +01:00
Frediano Ziglio
8d969b66ed test-quic: Test fixed images
QUIC uses different methods to reduce image size.
One uses RLE on pixels. Using fixed images allows to better
test these paths increase code coverage.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-06 12:22:09 +01:00
Frediano Ziglio
5b93090e60 test-utils: Add missing include file
In some environment memset was not declared.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
2020-05-06 12:21:10 +01:00
Frediano Ziglio
c00a152e00 build: Remove dependencies to libgthread
libgthread was needed to call g_thread_init.
This was removed by this commit:

    commit 3e116a6c71
    Date:   Wed Feb 6 13:32:09 2019 +0000

        Obsolete Glib cleanup

        We require at least GLib 2.38, remove code and check to
        support earlier versions.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-04-29 15:27:20 +01:00
Frediano Ziglio
7a84f60267 build: Remove dependency to gio2 from common and server libraries
The dependency is required only for client part.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-04-26 16:50:00 +01:00
Frediano Ziglio
4c6b360f6b canvas_base: Remove canvas_draw_blend/canvas_draw_copy duplication
The 2 functions are exactly the same.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-24 17:18:52 +01:00
Frediano Ziglio
3caedf3bc2 canvas_base: Rename blend to copy for canvas_draw_blend argument
SpiceCopy and SpiceBlend are typedefs of the same structure.
This to prove that canvas_draw_blend and canvas_draw_copy do
exactly the same thing.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-24 17:18:50 +01:00
Frediano Ziglio
a971c59166 canvas_base: Format canvas_draw_blend similarly to canvas_draw_copy
Just minor style changes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-24 17:18:45 +01:00
Frediano Ziglio
05c0c26839 agent: Fix incompatibility with Visual Studio compiler
Flexible arrays cannot have other fields following, even
if the fields are from a containing structure.
To fix this use an union and put the additional field inside
other structure in the union.
The final layout is the same but the compiler is not complaining.
This works on both GCC and Visual Studio.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 09:42:46 +01:00
Frediano Ziglio
bb03ff099b Add helper code for agent messages
Add agent.h and agent.c to deal with some common agent job:
- checking message from network and fixing network order.
- send back file transfer status.

Code based on Linux agent and Windows agent.
AgentXxxx and agent_xxx are used to avoid conflicts with protocol.

See agent.h for more detail on how to use these APIs.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-24 09:42:46 +01:00
Frediano Ziglio
8470ef9df2 helper-fuzzer-demarshallers: Add an helper for fuzzy testing demarshallers code
See usage with AFL in the source file initial comment.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-09 09:11:04 +01:00
Frediano Ziglio
402bc6b237 build: Allows to request a greater SPICE protocol version
Containing project can request a greater SPICE protocol version.
This will be taken into account while checking our requirements.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-04-08 14:28:40 +01:00
Frediano Ziglio
47e149705a proto: Generate correct constants for smartcard support
Of all SPICE_MSGC_SMARTCARD_xxx constants only SPICE_MSGC_SMARTCARD_DATA
is used by both spice-gtk and spice-server.
Generate the right constant, all obsolete ones will not be generated.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-04-07 11:07:33 +01:00
Frediano Ziglio
81f0331469 messages: Remove obsolete structure definition
This structure is not used by both spice-gtk and spice-server.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-04-07 11:07:23 +01:00
Frediano Ziglio
61ce54ef6c proto: Allows to specify @deprecated option for flags and enums
We want to obsolete from enumeration values, currently CELT.
The removal of check in has_attr is not an issue, as the attributes
are already checked by fix_attributes calls.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-04-07 10:22:33 +01:00
Frediano Ziglio
713a3e09fb build: Allow to build disabling code generation
Reduce dependencies if used by agents which do not need
marshallers/demarshallers code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-03 14:31:26 +01:00
Kevin Pouget
8f9eb611f8 spice.proto: add quality_indicator messages
These messages are used to exchange Streaming Quality messages between
SPICE client and SPICE server:

- `SPICE_MSGC_MAIN_QUALITY_INDICATOR`: a client->server message on the
  Main channel. This message is used by the client to share streaming
  quality observation with the server and the adaptive streaming
  control center. The format of the string message is not specified
  yet, it will depend of the sender/receiver final implementation.

- `SPICE_MSG_DISPLAY_QUALITY_INDICATOR`: a server->client message on
  the Display channel. This message is used to inform the client about
  adaptive-streaming specific details. The client should use it to
  configure its quality-message generation algorithms. The format of
  the string message is not specified yet, it will depend of the
  sender/receiver final implementation.

As an example, a `SPICE_MSG_DISPLAY_QUALITY_INDICATOR` message can
inform the client about the requested framerate (say, 60 FPS); and the
client will send a `SPICE_MSGC_MAIN_QUALITY_INDICATOR` warning message
when the measured framerate drops below 45 FPS.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-02 13:32:04 +01:00
Frediano Ziglio
911a7aa9c6 ci: Use spice-protocol master for make-win job
All other projects just use master version of spice-protocol.
Do this also on Windows to use the last sources, it could happen
that we need them and not last packaged version.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-22 10:32:22 +00:00
Frediano Ziglio
6a64d86d1d test-logging: Do not use G_PASTE to join level
"level" can have value "DEBUG". In some environment "DEBUG" is
used as preprocessor name to enable some debugging code.
Using -DDEBUG option (or similar) cause "DEBUG" to be defined as "1"
so "G_PASTE(G_LOG_LEVEL_, level)" will be expanded to "G_LOG_LEVEL_1"
instead of "G_LOG_LEVEL_DEBUG".
Just concatenate the two literal to avoid "DEBUG" expansion.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-03-19 14:47:08 +00:00
Frediano Ziglio
365d7019d5 lz_common: Remove unused commented out define
The DEBUG macro is not used in lz code (or even spice-common).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-17 17:08:17 +00:00
Frediano Ziglio
35a9debe93 ci: Fix build of spice-protocol
spice-protocol is not using Autoconf anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2020-03-17 17:07:29 +00:00
Victor Toso
31a14b20d0 sound: remove celt support
Follow up of spice-protocol's deprecation of celt mode.
See: https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/15

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-17 16:38:10 +00:00
Frediano Ziglio
11009d1b64 build: Use warning_level option for Meson
warning_level 2 setting for Meson add the same "-Wall -Wextra"
options to GCC compiler.
This removes a warning using Meson.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-03-12 12:48:39 +00:00
Frediano Ziglio
a3ec7c173d test-utils: Add a test for some utils.h functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-03-05 18:38:12 +00:00
Kevin Pouget
ec4e44200a utils: add set_bitmap/test_bitmap functions
This patch introduces `set_bitmap` and `test_bitmap` + relevant
macros, adapted from `<qemu>/include/qemu/bitops.h`.

These functions differ from `set_bit`/`test_bit` as they can set/test
bits in bit arrays longer than scalar data-types.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-04 16:43:48 +00:00