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

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

 



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 <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;
             }
         }
         if (ret == 0) {
-- 
2.17.2

_______________________________________________
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]