Commit Graph

2487 Commits

Author SHA1 Message Date
Christophe Fergeau
14b2f053ab test-vdagent: Pass proper types to spice_server_add_interface
This is a revert of 93b4f4050^ and 93b4f4050.
For a SpiceCharDeviceInstance, the base interface must be a
SpiceCharDeviceInterface instance, not a SpiceBaseInterface instance, or
spice-server code will end up reading out of bounds.

vmc_state/vmc_write/vmc_read implementations also have to be provided.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 12:13:55 +01:00
Christophe Fergeau
e87d0a3a84 gstreamer: Remove unused function
rate_control_is_active() is static and not used in gstreamer-encoder.c

Not needed since 97fcad82eb.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-02-15 10:50:27 +00:00
Frediano Ziglio
5a922af9e6 spicevmc: Add some statistics
Allows to see compressed/uncompressed ratio

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:16:16 +00:00
Frediano Ziglio
ce06958fb8 Improve statistic code interface
Use new structures and functions to implement the statistics code.
Use inline functions instead of macros for increased type-safety.
If statistics are disabled, the structures and functions become
empty. This confines the configuration-specific #defines to the
statistics implementation itself and avoids the need for #defines in
the calling functions. This greatly reduces the chance of accidentally
breaking the build for one configuration or the other. The reds option
was removed from stat_inc_counter() as it was not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:13:48 +00:00
Frediano Ziglio
469b94eb4e Do not set not blocking flag twice
Non blocking flag is set for all connection inside reds.c so
there's no need to set again for the single client channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 10:08:24 +00:00
Frediano Ziglio
f603f17317 red-channel-client: Pass array size to red_channel_client_prepare_out_msg
Do not make it assume vec contains IOV_MAX elements.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:02:27 +00:00
Frediano Ziglio
317457221d red-channel-client: Remove vec field from OutgoingHandler
This was always set to vec_buf.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:02:22 +00:00
Christophe Fergeau
3ef913a388 rcc: Rename {Outgoing,Incoming}Handler
They no longer contain any vfuncs, so calling them "handler" does not
make a lot of sense. This commit renames them to
OutgoingMessageBuffer/IncomingMessageBuffer.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:48:01 +01:00
Christophe Fergeau
65501eb13c rcc: Remove red-channel-client-private.h
Nothing outside of RedChannelClient needs access to data contained in
RedChannelClientPrivate, so we can move all the type definitions to the
.c file to make it fully opaque rather than relying on a private header.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
31a5182bd2 rcc: Move SpiceDataHeaderOpaque to red-channel-client-private.h
It's only used by red-channel-client.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
d4938694e2 rcc: Replace 'opaque' arg with typed RedChannelClient
The methods previously used by OutgoingHandlerInterface and
IncomingHandlerInterface are no longer used as generic callbacks,
but are directly called from RedChannelClient code. We can be explicit
about the type of their first argument (RedChannelClient *) rather than
using a generic void * pointer.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
7ffc7ed303 rcc: Pass RedChannelClient to red_peer_handle_outgoing()
There is only one implementation of OutgoingHandler which relies
OutgoingHandler::opaque being a RedChannelClient. This commit makes this
explicit in order to get rid of the OutgoingHandler::opaque data member.

This renames red_peer_handle_outgoing() to
red_channel_client_handle_outgoing() as the method is now very much tied
to RedChannelClient.

If we want to keep some genericity, we could return error codes from
red_channel_client_handle_outgoing() and handle RedChannelClient
disconnection/... from the caller rather than directly in the
_handle_outgoing() method. This would probably allow to move the
data reading logic to reds-stream.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
d6126bf495 rcc: Pass RedChannelClient to red_peer_handle_incoming()
There is only one implementation of IncomingHandler which relies
IncomingHandler::opaque to be a RedChannlClient. This commit makes this
explicit. This allows to get rid of the IncomingHandler::opaque data
member.

This renames red_peer_handle_incoming() to
red_channel_client_handle_incoming() as the method is now very much tied
to RedChannelClient.

If we want to keep some genericity, we could return error codes from
red_channel_client_handle_incoming() and handle RedChannelClient
disconnection/... from the caller rather than directly in the
_handle_incoming() method. This would probably allow to move the
data reading logic to reds-stream.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
f93fe59c21 channel: Remove IncomingHandlerInterface
This commit removes what remains of IncomingHandlerInterface. The
remaining function pointers were pointing to RedChannel vfuncs.
Moreover the IncomingHandlerInterface abstraction is unused, ie the
codebase only has a single implementation for it, so we can directly
call the relevant methods and make them static instead.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
99641c6874 channel: More removal of IncomingHandlerInterface vfuncs
This commit removes IncomingHandlerInterface::on_error and
IncomingHandlerInterface::on_input. As with previous commits, these
vfuncs are always calling the method, and RedChannel::init sets them to
point to RedChannelClient methods, which RedChannelClient is then going
to call indirectly through the IncomingHandlerInterface instance.

This commit changes this to direct calls to the corresponding methods.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
725c5fd323 channel: Remove IncomingHandlerInterface::{alloc,release}_msg_buf
Similarly to the previous commits, this removes an indirection level,
IncomingHandlerInterface stores pointers to
alloc_recv_buf/release_recv_buf vfuncs, but these are always set to
RedChannel::alloc_recv_buf/RedChannel::release_recv_buf, which are also
vfuncs which can be overridden if needed. This commit removes the
indirection and directly calls the relevant methods.

These vfuncs really should be in RedChannelClient rather than
RedChannel.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
c166cf3f24 channel: Remove OutgoingHandlerInterface
RedChannel uses OutgoingHandlerInterface to provide constant pointers to
RedChannelClient methods. This OutgoingHandlerInterface structure is
then used in RedChannelClient to indirectly call these methods.

The OutgoingHandlerInterface abstraction is unused, ie the codebase
only has a single implementation for it, so we can directly call the
relevant methods and make them static instead.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <figlio@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
a5471ea9b2 channel: Rework red_channel_on_output a bit
Have the RedChannelClient callback call into a RedChannel callback
rather than doing the opposite. This will be useful in some subsequent
refactoring of this code.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-15 08:47:52 +01:00
Christophe Fergeau
03ab893412 channel: Remove RedChannel::handle_parsed
red_channel_client_parse() currently does roughly:

if (klass->parser) {
    parsed = klass->parser(msg, msg_size, &parsed_size);
    klass->handle_parsed(rcc, parsed_size, msg_type, parsed);
} else {
    klass->handle_message(rcc, msg_type, msg, msg_size);
}

The handle_parsed implementation expects a void * 'parsed' argument,
which will then be cast to the correct type. There is not really a need
to provide distinct handle_parsed/handle_message vfuncs, instead we can
say that if a RedChannel subclass provides a 'parser' vfunc, then it's
'handle_message' vfunc will be called with the parsed message, otherwise
it will be called with unparsed data (ie what handle_message currently
expects).

This makes the code slightly easier to follow as messages will always be
handled by the same vfunc.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-15 08:47:52 +01:00
Frediano Ziglio
b8f4b3338b smartcard: Remove an unnecessary wrapper function
smartcard_channel_client_pipe_add_push was just calling
red_channel_client_pipe_add_push without any cast or other
changes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-14 18:07:54 +00:00
Christophe Fergeau
4c2817a562 channel: Remove unused vfunc typedefs from header
They became unused more than 5 years ago in commit f84dfe

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-13 16:41:01 +00:00
Christophe Fergeau
e9461ec904 Move variables to inner block in red_peer_handle_incoming()
This makes the code slightly more readable as this means less local
variables to keep track of when taking a high level view of that code.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-10 16:32:56 +01:00
Frediano Ziglio
cb84a6c2ed replay: Avoid double free of primary surface
read_binary() attaches 'mem' to the SpiceReplay::allocated list.

On failure, SpiceReplay::allocated and its content are freed by
spice_replay_free().

SpiceReplay::primary_mem is also freed, which causes a double free
as replay_handle_create_primary() added 'mem' both to
SpiceReplay::primary_mem and SpiceReplay::allocated.

This commit avoids this by ensuring SpiceReplay::primary_mem is not
kept in the SpiceReplay::allocated list.

Note that this double free can happen only on currupted or wrong
record images.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-08 20:53:44 +00:00
Jonathon Jongsma
11629023c4 DisplayChannel: add documentation for Ring types
The Surface and Display channels each have a 'current_list' Ring, and
Surface also has a 'current' Ring. these names are confusing, so at
minimum, add a comment indicating the type of object they hold. The
DisplayChannel::current_list already had a comment, but it was
incorrect.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-06 16:19:04 -06:00
Jonathon Jongsma
43f62e46ca Shadow: remove unused 'owner' field
This field is set but is never read. The only usage of this field was
removed in 3dffeb25ed

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-06 10:12:15 +00:00
Frediano Ziglio
a44a735cda replay: Support TLS in replay utility
Allows to test encrypted connections.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-06 10:06:09 +00:00
Frediano Ziglio
1d3e26c0ee main-channel: Prevent overflow reading messages from client
Caller is supposed the function return a buffer able to store
size bytes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-06 09:13:11 +00:00
Frediano Ziglio
e16eee1d8b Prevent integer overflows in capability checks
The limits for capabilities are specified using 32 bit unsigned integers.
This could cause possible integer overflows causing buffer overflows.
For instance the sum of num_common_caps and num_caps can be 0 avoiding
additional checks.
As the link message is now capped to 4096 and the capabilities are
contained in the link message limit the capabilities to 1024
(capabilities are expressed in number of uint32_t items).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-06 09:13:08 +00:00
Frediano Ziglio
ec124b982a Prevent possible DoS attempts during protocol handshake
The limit for link message is specified using a 32 bit unsigned integer.
This could cause possible DoS due to excessive memory allocations and
some possible crashes.
For instance a value >= 2^31 causes a spice_assert to be triggered in
async_read_handler (reds-stream.c) due to an integer overflow at this
line:

   int n = async->end - async->now;

This could be easily triggered with a program like

  #!/usr/bin/env python

  import socket
  import time
  from struct import pack

  server = '127.0.0.1'
  port = 5900

  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((server, port))
  data = pack('<4sIII', 'REDQ', 2, 2, 0xaaaaaaaa)
  s.send(data)

  time.sleep(1)

without requiring any authentication (the same can be done
with TLS).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-06 09:13:05 +00:00
Frediano Ziglio
cd82c9f698 sound: Use default message handler if possible
red_channel_client_handle_message can handle base messages
so reuse it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-03 18:14:46 +00:00
Frediano Ziglio
6be1c2f839 stat-file: Avoid compiler warning
Some gcc version reports this error:

stat-file.c: In function 'stat_file_add_node':
stat-file.c:180:15: error: 'node' may be used uninitialized in this function
[-Werror=maybe-uninitialized]
     g_strlcpy(node->name, name, sizeof(node->name));
               ^~~~
cc1: all warnings being treated as errors

This warning is a false positive as this loop:
    for (ref = 0; ref <= stat_file->max_nodes; ref++) {
        node = &stat_file->stat->nodes[ref];
        ...
    }
will always iterate at least once.

This patch rewrite the loop in order to make more compilers
understand that node variable is always initialized.

There are two checks apparently removed in the patch:
- check for stat_file->stat not being NULL. This was worthless as the
  field was already used in the function. Also this field is never
  NULL (unless memory corruption happened);
- stat_file->stat->num_of_nodes >= stat_file->max_nodes. It's implicit
  in the loop. If num_of_nodes >= max_nodes means that there are no
  free nodes so all nodes should have SPICE_STAT_NODE_FLAG_ENABLED set,
  loop will exit and function will return INVALID_STAT_REF.

Reported-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-03 18:13:22 +00:00
Frediano Ziglio
a29afab028 stat-file: Fix off by one buffer overflow
The stat file contains an array of max_nodes elements
so we must stay in [0, max_nodes) range, not [0, max_nodes].

There are no spice path that lead to these overflows but
it's better to have them fixed before creating one.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-03 09:48:46 +00:00
Snir Sheriber
1004748c46 autotools: compile gst-test only if gstreamer is available
Needed in order to avoid compilation error when gstreamer is
unavailable
2017-02-03 09:08:55 +01:00
Snir Sheriber
c9987b0fd5 autotools: Add automake conditional for gstreamer
Adding conditional for having gstreamer_0_10 or gstreamer_1_0,
removing the previous conditionals and update relevant ifdefs
with the newly defined conditional
2017-02-03 09:08:55 +01:00
Frediano Ziglio
3066ebe33b sound: Make clear active and client_active are boolean
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:58:44 +00:00
Frediano Ziglio
7cb27a209e sound: Reuse code to set volume and mute
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:58:44 +00:00
Frediano Ziglio
6128aae6d2 sound: Reuse code for migrating client channels
We support only a single client so don't waste code just
to check this.
The worst stuff can happen is that we'll migrate multiple
connections.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:57:01 +00:00
Frediano Ziglio
f6406bbaae sound: Reuse code for snd_set_{playback,record}_peer
Almost identical beside the type.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:57:01 +00:00
Frediano Ziglio
46ed676eb5 sound: Use default disconnect for client channels
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:51:38 +00:00
Frediano Ziglio
92c051a820 sound: free SndChannel data in finalize()
Move the freeing of SndChannel data members from snd_detach_common() to
the finalize function to encapsulate things a bit more cleanly. It
doesn't really change the behavior or order of destruction since
snd_detach_common() destroys the channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:51:38 +00:00
Frediano Ziglio
b7e4703140 Make RedChannelClient::incoming private
Sound implementation used internal RedChannelClient data while now
it just uses the public interface not thouching RedChannelClient
internal state so now is possible to make this field private.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-02 15:51:38 +00:00
Christophe Fergeau
d8dc09b817 sound: Convert SndChannelClient to RedChannelClient
Now that SndChannelClient has switched from using its own code for
sending data to using RedChannelClient, it's very close to being an
actual RedChannelClient.
This commit makes it directly inherit from RedChannelClient rather than
having a channel_client field. This allows to get rid of the whole
DummyChannel/DummyChannelClient code.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-02 16:31:05 +01:00
Christophe Fergeau
39c22ee98f sound: Prefer snd_set_command() over snd_*_send_*()
snd_set_command()/snd_send() are higher level methods which take care of
scheduling calls to the corresponding snd_*_send_*() methods when
appropriate. This commit switches a few direct snd_*_send_*() calls to
snd_set_command()/snd_send().

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:05 +01:00
Christophe Fergeau
7ea1f2c133 sound: Use RedChannelClient to receive/send data
You can see that SndChannelClient has much less field
as the code to read/write from/to client is reused from
RedChannelClient instead of creating a fake RedChannelClient
just to make the system happy.

One of the different between the old sound code and all other
RedChannelClient objects was that the sound channel don't use
a queue while RedChannelClient use RedPipeItem object. This was
the main reason why RedChannelClient was not used. To implement
the old behaviour a "persistent_pipe_item" is used. This RedPipeItem
will be queued to RedChannelClient (only one!) so signal code we
have data to send. The {playback,record}_channel_send_item will
then send the messages to the client using RedChannelClient functions.
For this reason snd_reset_send_data is replaced by a call to
red_channel_client_init_send_data and snd_begin_send_message is
replaced by red_channel_client_begin_send_message.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-02 16:31:05 +01:00
Christophe Fergeau
cb0e45cd16 sound: Remove code from spice_server_record_get_samples()
The removed code was trying to read data when
spice_server_record_get_samples() is called. Since reading of data is
event-driven anyway (see snd_event), it's redundant to try
again to read more data.
This commit removes this code as this will some refactoring easier in
the next commits.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:04 +01:00
Christophe Fergeau
4bb9c1fe56 sound: Remove SndChannelClient::channel
We can get it from our DummyChannelClient rather than storing it in
SndChannelClient.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:04 +01:00
Christophe Fergeau
bc2a510438 sound: Remove SndChannelClient::send_data::marshaller
We can use the marshaller provided by the dummy RedChannelClient
associated with SndChannelClient.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:04 +01:00
Christophe Fergeau
85b73636d9 sound: Add sanity checks in snd_{playback,record}_send
Filter out commands which should not happen. Should it be a
g_warn_if_fail() or such instead?

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:04 +01:00
Christophe Fergeau
c4a58c90c6 sound: Implement snd_channel_config_socket
This is in preparation for switching SndChannelClient into a proper
RedChannelClient. The prototype of the new helper matches what is
expected from the RedChannel::config_socket vfunc.

To be able to achieve that, this commit associates the sound channel
RedsStream instance with the DummyChannelClient instance we have, and
then call snd_channel_config_socket() on that instance.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:04 +01:00
Christophe Fergeau
f5a972fdbf sound: Rework spice_server_playback_get_buffer() error handling
The main goal of this commit is to avoid to dereference 'client' before
it's checked for NULL. This meant splitting one error condition in 2
separate ones.

This also sets default values for the 'frame' and 'num-samples'
out parameters so that we just have to return on error conditions.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-02 16:31:04 +01:00