Commit Graph

867 Commits

Author SHA1 Message Date
Christophe Fergeau
2f64e2edbb lz: Don't try to print uninitialized variable
encoder->type is only going to be set by lz_set_sizes() after the
error() call. We can use 'type' directly which is what encoder->type is
going to be set to.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 11:29:25 +01:00
Christophe Fergeau
187df0cfdb backtrace: Add missing include
This fixes a warning about missing prototype for backtrace()

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 11:29:25 +01:00
Christophe Fergeau
79a9fad3a2 canvas_base: Fix variable shadowing warning
canvas_base.c is #included by spice-common users. They currently don't
enable this warning, but if/when they do, we don't want code from
spice-common to trigger it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-03-29 11:29:25 +01:00
Frediano Ziglio
bd75d3f934 Generate automatically most C message declarations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:02:03 +00:00
Frediano Ziglio
5f1f369e41 Allow to generate C declarations for spice.proto
Generate and include C declarations.
Next patch will use this facility.
Since none of the spice.proto types are decorated with @declare,
adding the #include in messages.h won't have any bad consequences.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:02:01 +00:00
Frediano Ziglio
3cd3886b27 codegen: Allows to generate C declarations automatically
Allows to specify a @declare attribute for messages and structure
that can generate the needed C structures.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:01:58 +00:00
Frediano Ziglio
dac34baaab codegen: Generate headers while generating code
Python script generates code and header together however allowed
to save only one of them.
Allows to save both of them together to reduce number of time
we call Python script.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-18 13:01:52 +00:00
Frediano Ziglio
af66a4ccad codegen: Factor out a function to write output file
This will be reused to generate C declaration automatically.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-15 15:46:17 +00:00
Frediano Ziglio
81e2092fc7 meson: Remove some useless checks
Do not check for functions not used or available in C89 and earlier.
Autoconf check for them to support archaic systems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-03-15 15:45:57 +00:00
Frediano Ziglio
387d1842d1 test-ssl-verify: Improve subject_to_x509_name coverage
Check that attempting to quote an invalid character result in
a error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-13 17:22:18 +00:00
Frediano Ziglio
fce4486755 build: Remove snd_codec.h from EXTRA_DIST
The file is already distributed as included in the source list.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-13 10:58:28 +00:00
Frediano Ziglio
1cdc3cc3b0 ci: Remove dependencies from copr build
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2019-03-12 12:43:38 +00:00
Frediano Ziglio
cb00ccfaab codegen: Rename --prefix parameter to --suffix
The option is used to add a suffix to public functions, not a
prefix.
Currently the option is not used (it was used to generate protocol
1 code).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-08 21:22:58 +00:00
Frediano Ziglio
302e30ff43 codegen: Remove support for --ptrsize
This option was used in protocol 1 to generate 64 bit pointers.
A pointer in the protocol is an offset in the current message.
This allows the possibility to have messages with pointers with more
than 4GB. This feature was removed and not used in protocol 2.
The reason this feature was correctly removed in protocol 2 is that
having 64 bit pointers in the protocol would require messages larger
than 4GB which would cause:
- huge latency as a single message would take more than 4 seconds
  to be send in a 10Gb connection;
- huge memory requirements.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-08 11:09:02 +00:00
Frediano Ziglio
92d5dfd4bf messages: Remove fields not used by the protocol
These fields are not used by the protocol (not in spice.proto, nor
will be used in the generated (de)marshallers).
Avoid spice-gtk and spice-server to use them by mistake.
This can cause memory errors (data_size is not used or is not set
correctly) and useless code (spice-gtk uses the pub_key* fields but
these fields are not sent to the server as the protocol does not have
them).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-03-07 21:07:18 +00:00
Frediano Ziglio
db245ae740 protocol: Add a dummy TunnelChannel
The removal of the channel definition will cause the enumeration
to miss this old channel.
Add a dummy channel (empty) to avoid having to update spice-gtk
and spice-server and possibly breaking other software.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-03-05 23:19:53 +00:00
Frediano Ziglio
86136f9a95 proto: Remove obsolete TunnelChannel
No reason to keep it, spice-gtk and spice-server don't
implement it and was removed for security reasons.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2019-02-22 12:03:18 +00:00
Marc-André Lureau
c5e7d92dc6 docs: add spice URI scheme
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-21 14:22:18 +00:00
Frediano Ziglio
e8c76358ee log: Remove useless includes
Now the function almost uses GLib function, no reason to include
some system headers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-21 13:44:07 +00:00
Frediano Ziglio
4ccc20a7f6 mem: Fix compile error if alignment-checks option is used
Domain name argument to spice_log was removed time ago.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-21 13:44:07 +00:00
Frediano Ziglio
60883a0321 codegen: Add a test for attribute combination
Does not make sense to specify the same field to have 2
different C implementation at the same time.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-21 09:05:03 +00:00
Frediano Ziglio
a5de31bc8a codegen: Check wrong attribute
@ptr_array is supposed to change the destination to an array
of pointer to items. This for a raw buffer does not make sense
but check if user specifies this combination.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-20 17:45:29 +00:00
Frediano Ziglio
7462c171e1 codegen: Fix c_type result for TypeAlias
c_type() method is supposed to return the type to use for
C structure field. But the name is not a C type but a
protocol name.
Return the type name of the aliased type (for instance
uint32_t for a uint32 type).
This does not change the generated code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-20 17:42:59 +00:00
Frediano Ziglio
53c0c5a665 codegen: Reduce indentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-20 17:42:59 +00:00
Frediano Ziglio
7fa8bda275 codegen: Use a better type for pointer converted to integer
Although on the platform we support size_t and uintptr_t are
the same, on some platform the size_t can (in theory) be smaller
than the necessary integer to store a pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-20 17:42:59 +00:00
Frediano Ziglio
7f6c55790b codegen: Document ptr_array attribute
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-20 17:39:27 +00:00
Eduardo Lima (Etrunko)
02530a80df meson: Bump requirement to 0.48
This version is already required by spice-gtk and is soon to be required
by spice-server as well, so there is no much sense in keeping it for
spice-common.

It is necessary to update the usage of the python module as described in
the documentation:

https://mesonbuild.com/Release-notes-for-0-48-0.html#python3-module-is-deprecated

Which gets rid of the following warning message:

WARNING: Deprecated features used:
 * 0.48.0: {'python3 module'}

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-02-13 14:42:04 -02:00
Eduardo Lima (Etrunko)
811fff0791 meson: switch smartcard option to auto feature
In spice-gtk commit dbdf692909f7a2b272b06a674a38a1aeb4303032, the
smartcard option has been changed from boolean to feature, which
actually broke the option yeld, because the option type is incompatible
between superproject and subproject.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-02-13 14:20:03 -02:00
Eduardo Lima (Etrunko)
413da761ec meson: Bump libcacard requirement to 2.5.1
Commit 924f47 did this for autotools, do the same for meson.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-02-11 12:40:02 -02:00
Frediano Ziglio
3e116a6c71 Obsolete Glib cleanup
We require at least GLib 2.38, remove code and check to
support earlier versions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-02-06 14:24:03 +00:00
Frediano Ziglio
e3af47fe9d log: remove deprecated SPICE_DEBUG_LEVEL support
This feature was marked obsolete by efd1d3cb4d more than
three years ago.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-06 13:21:00 +00:00
Frediano Ziglio
ea20b8c013 log: remove deprecated SPICE_ABORT_LEVEL support
This feature was marked obsolete by efd1d3cb4d more than
three years ago.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-02-06 13:19:47 +00:00
Eduardo Lima (Etrunko)
e307130c18 meson: Use underscorify() instead of split()
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-02-01 14:40:47 -02:00
Frediano Ziglio
9ca8914b7c Remove obsolete Autoconf macros
Autoconf 2.63 was released on September 2008.
These simple macros conflict with system ones and can
causes issues with some systems (currently MacOS).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-30 13:14:40 +00:00
Frediano Ziglio
2e914f3305 Integrate recorder library
Allow to use recorder library. See https://github.com/c3d/recorder for
details.
The main usage will be to collect statistics while the programs will run.
By default the recorder will be disabled at compile time. The idea of the
usage in SPICE is to collect data while the program run. Using current
SPICE logging facility was discussed but not easy to filter data. Other
solutions (SystemTap, LTTng) were discarded due to not cross platform.
A printf based solution was discussed too but missing the additional tools
which are useful. Currently we don't plan to use as extensively as to be a
problem to be replaced or removed in the future.

Both Autoconf and Meson build systems are supported.
Autoconf requires the addition of SPICE_CHECK_RECORDER call in configure.ac.
Meson requires to add recorder option.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-01-23 14:44:19 +00:00
Marc-André Lureau
0a753b93b5 meson: fix building for big-endian host
autofoo build-sys defines WORDS_BIGENDIAN, and spice-common code uses it.

Later, I think it would make sense to switch to G_BIG_ENDIAN instead.

Fixes:
https://gitlab.freedesktop.org/spice/spice-common/issues/2

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-01-17 12:46:23 +04:00
Marc-André Lureau
6c09f943ce quic: fix sign-compare warning
../subprojects/spice-common/common/quic.c: In function 'fill_model_structures':
../subprojects/spice-common/common/quic.c:695:55: error: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Werror=sign-compare]
     spice_assert(free_counter - family_stat->counters == nbuckets * ncounters);
                                                       ^~

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <figlio@redhat.com>
2019-01-17 12:45:10 +04:00
Marc-André Lureau
57f2c61712 build-sys: improve asciidoc rules to allow multiple targets
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-01-15 17:35:58 +04:00
Marc-André Lureau
96700c849d Add a .gitpublish
That makes it easier to send patch series for spice-common.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-01-15 17:35:51 +04:00
Frediano Ziglio
5173ff871a lz: More checks on image sizes
Extend sizes check also to decoding, actually the source data
decoding images should be less safe than encoding.
This avoids different integer overflows and buffer overflows.
To avoid potential issues images are limited to 1GB.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-08 21:27:45 +00:00
Frediano Ziglio
3050b4e1f6 lz: Avoid buffer reading overflow checking for image type
The type of the image is just copied from network without
any check and later used for array indexing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-01-08 21:27:45 +00:00
Frediano Ziglio
16aa8c98d8 test: Add a test for subject_to_x509_name function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-08 21:26:58 +00:00
Frediano Ziglio
3e6dedaa51 marshaller: Provide spice_marshaller_fill_iovec for Windows
An array of WSABUF can be used with WSASend.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-08 13:05:20 +00:00
Marc-André Lureau
924f47a653 Bump libcacard requirement to 2.5.1
v2.5.1 was released on 2015-11-24.

According to repology, from the distro we care about, CentOS 6,
openSUSE Leap 42.3 have too old version (0.1.2).

spice-gtk & spice-server will have to be updated to drop
USE_SMARTCARD_012.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-08 13:12:55 +04:00
Frediano Ziglio
6dc745e877 log: Use proper format attribute for spice_log
SPICE_ATTR_PRINTF uses __printf__ format attribute.
spice_log internally uses g_string_append_vprintf which uses
G_GNUC_PRINTF attribute.
G_GNUC_PRINTF can be __printf__ or gnu_printf format which in
some systems (currently Windows) can be different.
GLib 2.58 changed G_GNUC_PRINTF on Windows from using __printf__
attribute to gnu_printf.
To avoid problems in the future uses G_GNUC_PRINTF instead of
SPICE_ATTR_PRINTF for spice_log.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2019-01-02 14:00:23 +00:00
Frediano Ziglio
2d32025f77 Use a single copy of subject string
A full copy can keep both the key and the value instead of allocating
twice the memory.
We are parsing key1=val1,key2=val2,... and in doing that, we currently
store 'key1' in key, and 'val1' in val, and then 'key2', 'val2', and so
on.
After this patch, we store 'key1\0val1\0' in key, which fits and saves
some memory.
Also this removes a warning produced by Coverity that is assuming that
allocating strlen(string_variable) is wrong.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-12-19 11:31:13 +00:00
Frediano Ziglio
7f4da3ff36 ci: Run tests on Windows using wine
As spice-common is used by spice-gtk which should run on Windows
even spice-common should compile and run on Windows so check it
with CI.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-12-17 12:18:48 +00:00
Frediano Ziglio
c01a4a6fc3 test-region: Add missing dependencies
The test uses both GLib and pixman libraries.
This does not seem to affect Linux but make the test fails under Windows.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-17 12:18:48 +00:00
Frediano Ziglio
a45f656aac test-marshaller: Make main declaration easier
Declare without argument instead of long declaration.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-17 09:54:56 +00:00
Frediano Ziglio
ac8d27104b test-marshaller: Make test_overflow static
Not used outside the test.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-12-17 09:52:29 +00:00