Re: [PATCH spice-gtk] spice-channel: Avoids spice_channel_read_wire returning success

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx>
with the log improved.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]