Although is really unlikely that errno get <= 0 do not returns a
valid result for a failure from spice_channel_read_wire.
Such results could end up in buffer overflows.
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 is also set to an invalid
value to check if some function (like strtod) modify it.
This is more a safety but better safe than sorry.

Signed-off-by: Frediano Ziglio <fzig...@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;
             }
         }
         if (ret == 0) {
-- 
2.17.2

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

Reply via email to