Commit Graph

3517 Commits

Author SHA1 Message Date
Uri Lublin
7edd55d95b image_encoders_free_glz_drawables: enc is never NULL
It is called from 2 places.
1. display-channel.cpp:
   dcc_get_encoders always returns a non-null pointer.
2. image-encoders.cpp: image_encoders_release_glz
   <- image_encoders_free (where enc is not checked)
   <- dcc.c:image_encoders_free
   where non-null pointer is passed.

Signed-off-by: Uri Lublin <uril@redhat.com>
2020-06-19 10:50:58 +01:00
Frediano Ziglio
8875e79c7c reds: Use socket_close instead of close
socket_close is mapped to close under Unix but under Windows
you should call closesocket instead so call socket_close which
will map to the proper close function on both environments.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-06-18 16:57:50 +01:00
Uri Lublin
21323c8b6f glz_dictionary_window_add_image: error out when failed to alloc an image
__glz_dictionary_window_alloc_image may return NULL.
Check that the image was created successfully and if not
then error out using dict->cur_usr->error like it's done
few lines below.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:53:22 +01:00
Uri Lublin
031ab732dd glz_enc_dictionary_restore: return NULL upon failure
glz_enc_dictionary_create may return NULL.
glz_enc_dictionary_restore itself may return NULL so
add one more check.

Found-by: gcc (10) analyzer

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:53:19 +01:00
Uri Lublin
954eabaeb7 test-websocket: check setsockopt return value
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:48:25 +01:00
Frediano Ziglio
982d14dd69 dispatcher: Move some private functions to DispatcherPrivate
Reduce declaration in the header.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-17 10:59:38 +02:00
Frediano Ziglio
b8f4d7d2c7 websocket: Fix possible integer overflow
The shift of a uint_8 number by a number > 32 causes an overflow.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-06-16 15:17:06 +01:00
Frediano Ziglio
70347f3175 dcc: Remove unused result from dcc_add_surface_area_image
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-16 11:27:53 +01:00
Frediano Ziglio
87b6b1993e sound: Make receive_buf field private
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-14 14:31:32 +01:00
Frediano Ziglio
87270d3037 basic-event-loop: Remove useless "ring.h" include
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-10 16:52:32 +01:00
Frediano Ziglio
4466230a85 red-parse-qxl: Add a note on red_get_cursor
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-10 10:13:20 +01:00
Frediano Ziglio
f03d094942 reds: Remove usage of "this"
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-08 10:00:43 +01:00
Frediano Ziglio
3c74601652 main-channel-client: Make some members const
Also use a more explicit return type.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-08 09:05:28 +01:00
Frediano Ziglio
64435c8934 main-channel: Fix typo in comment
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-07 20:51:07 +01:00
Frediano Ziglio
39c513b604 red-common: Fix typo in comment
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-04 11:07:32 +02:00
Frediano Ziglio
6c900f0442 inputs-channel-client: Avoid attribute shadowing
This regression was caused by commit
"2ffa7d00c60808e2f640df9bc9b5d62598455588"
(cfr "Improve encapsulation for InputsChannelClient")

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-06-04 09:34:18 +01:00
Frediano Ziglio
853a6df224 Avoid useless SPICE_CXX_GLIB_ALLOCATOR usage
Behaviour was already inherited.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-06-04 09:34:12 +01:00
Frediano Ziglio
4dbc6dae01 cursor-channel: Turn cursor_channel_reset into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:44 +01:00
Frediano Ziglio
e044c5bd50 cursor-channel: Turn cursor_channel_set_mouse_mode into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:42 +01:00
Frediano Ziglio
f30d35a8c7 cursor-channel: Turn cursor_channel_do_init into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:41 +01:00
Frediano Ziglio
0528fadff3 cursor-channel: Turn cursor_channel_process_cmd into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:38 +01:00
Frediano Ziglio
aa0dddde0f sound: Move define "trick" to spice-wrapped.h header
The spice-wrapped.h was introduced to deal with such tricks
in the code and limit them to a single place.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:36 +01:00
Frediano Ziglio
bd17418f9e char-device: Make RedCharDevice::write_retry private
Not meant to be called externally.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:36:11 +01:00
Frediano Ziglio
19f3406db6 spicevmc: Cleanup some "this" usage
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:34:03 +01:00
Frediano Ziglio
fc55e9fa27 image-encoders: Fix compile warnings for ARM7 platform
Compiling under ARM7 GCC compiler report these warning:

image-encoders.cpp: In function 'int lz4_usr_more_space(Lz4EncoderUsrContext*, uint8_t**)':
image-encoders.cpp:261:32: error: cast from 'Lz4EncoderUsrContext*' to 'Lz4Data*' increases required alignment of target type [-Werror=cast-align]
  261 |     EncoderData *usr_data = &(((Lz4Data *)usr)->data);
      |                                ^~~~~~~~~~~~~~
image-encoders.cpp: In function 'int lz4_usr_more_lines(Lz4EncoderUsrContext*, uint8_t**)':
image-encoders.cpp:329:32: error: cast from 'Lz4EncoderUsrContext*' to 'Lz4Data*' increases required alignment of target type [-Werror=cast-align]
  329 |     EncoderData *usr_data = &(((Lz4Data *)usr)->data);
      |                                ^~~~~~~~~~~~~~

In all other occurrences of these cast we are already using
SPICE_CONTAINEROF.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:32:41 +01:00
Frediano Ziglio
88c25a18de Fix compatibility with TCP sockets and Darwin
Using socket pairs and trying to set a TCP level option on the
socket setsockopt returns EINVAL error and not ENOTSUP as
expected.
Check this case and handle as ENOTSUP (ignoring it).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
4f82cec197 Fix compatibility with ENOTSUP and Darwin
Darwin uses also the constant EOPNOTSUPP for the same reasons.
In some versions EOPNOTSUPP is defined as ENOTSUP.
Check both values, not only ENOTSUP.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
90453ddf06 Fix compatibility with TCP_KEEPIDLE and Darwin
Darwin uses for the same setting the TCP_KEEPALIVE option.
Use TCP_KEEPALIVE instead of TCP_KEEPIDLE for Darwin.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
6684a3b5ef Fix compatibility with pthread_setname_np and Darwin
On Darwin pthread_setname_np accepts only an argument and
set current thread name.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
ee4cf6a07c Fix compatibility with MSG_NOSIGNAL and Darwin
Darwin does not have MSG_NOSIGNAL but allows to set a SO_NOSIGPIPE
option to disable sending SIGPIPE writing to closed socket.
Note that *BSD has the SO_NOSIGPIPE option but does not affect all
write calls so instead continue to use MSG_NOSIGNAL instead on
that systems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Kevin Pouget
2d971c6ec0 server/meson.build: fix bug when project version is unknown
When `build-aux/git-version-gen` is not able to find the project
version (no git tags and no `.tarball-version`), it returns 'UNKNOWN'
(instead of the project version like `0.14.3.185-15b1`).

This `UNKNOWN` value fails `meson build` command:

    server/meson.build:8:0: ERROR: Index 1 out of bounds of array of size 1.

With this patch, we set a default major/minor/micro value when the
actual version is unknown. This is the same as the `autoconf`
historical behavior.

Fixes #41.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:49:43 +02:00
Gilmar Santos Jr
15b1e2a3bb red-stream: WebDAV doesn't work when SASL is active
When SASL is active, if a read request is made and SASL buffer contains some
data (but not enough to fulfill the request), upon return the taken data from
the buffer is not accounted for and hence part of the message gets discarded.

red_stream_sasl_read function takes available data from sasl buffer and returns
if it's enough. If it's not, nbyte is decremented and buf pointer is
incremented to account for the taken data (if any). Then it tries to get more
data from the socket and decode it.

Suppose there was some data in the sasl buffer, but not enough. Then the socket
is not readable (EAGAIN, EINTR, whatever) or the new data isn't enough for
sasl_decode (hence decodedlen == 0). In both cases the function returns as if
no data was read, but it took some data from sasl buffer. This data is lost and
from this point on the communication ceases on the channel (eventually new data
is read, but messages are corrupt without the parts previously discarded).

On the other hand, if some data is read from sasl buffer and everything else
works fine, the output buffer contains all the data, but the count returned
only inform the caller about the newly read data (which causes the similar
effect of discarding part of the message).

Fixes: https://gitlab.freedesktop.org/spice/spice/-/issues/40

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-11 19:09:15 +01:00
Frediano Ziglio
21f9d25aa8 Update filenames in comments
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-11 08:14:47 +01:00
Frediano Ziglio
a21e66b7b3 test-dispatcher: Test dispatcher
Test that dispatcher work.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-05 05:15:43 +01:00
Frediano Ziglio
09e01153b7 utils: Fix typo in comment 2020-05-05 05:14:53 +01:00
Frediano Ziglio
62801ad9ac char-device: Remove obsolete declaration
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-05 05:14:53 +01:00
Frediano Ziglio
851b136bb4 sound: Make functions exported not visible
Allows the compiler to do some additional optimizations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
46cda65123 build: Remove GObject dependency
Not used anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
31f0ce2086 Avoids registering type just to get the nick of an enum value
We don't use anymore GObject parameters so avoid having to
register enum values to GType system to use them.
We just need to get the nick value of the enum values for
debug purposes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
fd06625ba1 red-stream-device: Better encapsulation
Remove all members public, set correct access and create
missing methods.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
1e9205a3b8 char-device: Remove GObject from RedCharDevice
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
f6f998004b Wrap spice.h in order to do some adjustment
Instead of including spice.h directly include an header that wraps
it. This allows to remove the SPICE_SERVER_INTERNAL define.
Currently is used to rename SpiceCharDeviceInstance to RedCharDevice
and reduce its visibility to hidden. This remove some warnings
and some weird code in the source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
be5bda4d4f utils: Add red::weak_ptr and red::shared_ptr_counted_weak
Implements weak pointers and helper to implement them.
They will be used for RedCharDevice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2b9e1dcd55 dispatcher: Reuse base reference counting for Dispatcher hierararchy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
724f23e4bd Use red::shared_ptr_counted for RedChannelClient
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
597461e443 Add and use red::make_shared
Allow to create an object already contained in a shared pointer
to avoid having not owned objects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
5126e38367 Use shared_ptr implementation to handle reference counting
This allows to make easier the management of owning.
Reference counting is automatically updated based on shared
pointers modification.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
bf04d7d721 utils: Very skinny share_ptr implementation for our references
It will be used to refactor reference counting code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
54c0830919 input-channels: Improve encapsulation
Update member access to limit it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
b28db35af5 reds: Make mig_wait_disconnect_clients a std::forward_list
In the meanwhile remove a leak on the program.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00