[Spice-devel] [PATCH spice-gtk] spice-channel: Avoids spice_channel_read_wire returning success
Christophe Fergeau
cfergeau at redhat.com
Thu Nov 22 13:46:43 UTC 2018
Hey,
I'm having a hard time reading the commit log.
The shortlog could be
spice-channel: Don't return 0 when spice_channel_read_wire failed
On Thu, Nov 22, 2018 at 09:17:17AM +0000, Frediano Ziglio wrote:
> Although is really unlikely that errno get <= 0 do not returns a
> valid result for a failure from spice_channel_read_wire.
"Although it is really unlikely that errno is <= 0, we should still make
sure spice_channel_read_wire failures are correctly reported in that
event as well.
> Such results could end up in buffer overflows.
> errno is not always set (for instance GLib functions prefer to
Maybe start with "Moreover, "
> set a GError instead or Windows uses WSASetLastError to store
> sockets function errors). Sometimes is also set to an invalid
Sometimes _it_ is also set ...
> value to check if some function (like strtod) modify it.
modifies/modified
> This is more a safety but better safe than sorry.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> src/spice-channel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 602869e1..e6110b0a 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -1060,7 +1060,7 @@ static int spice_channel_read_wire(SpiceChannel *channel, void *data, size_t len
> continue;
> } else {
> c->has_error = TRUE;
> - return -errno;
> + return errno > 0 ? -errno : -EIO;
This could almost be
g_return_val_if_fail(errno > 0, -EIO);
return -errno;
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
with the log improved.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20181122/a59fc5b5/attachment.sig>
More information about the Spice-devel
mailing list