[Spice-commits] src/spice-channel.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 22 15:23:36 UTC 2018


 src/spice-channel.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 101397fb2bfe4ee855b325330b1e2331e7fce009
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Nov 21 10:16:48 2018 +0000

    spice-channel: Avoids spice_channel_read_wire returning success
    
    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.
    Moreover, errno is not always set (for instance GLib functions prefer
    to set a GError instead or Windows uses WSASetLastError to store
    sockets function errors). Sometimes it is also set to an invalid value
    to check if some function (like strtod) modifies it.
    This is more a safety but better safe than sorry.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/src/spice-channel.c b/src/spice-channel.c
index 7c54ab0..c61bcba 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;
             }
         }
         if (ret == 0) {


More information about the Spice-commits mailing list