vnc: Don't assert if opening unix socket fails
authorCole Robinson <crobinso@redhat.com>
Tue, 5 May 2015 15:07:17 +0000 (11:07 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 20 May 2015 08:23:08 +0000 (10:23 +0200)
Reproducer:

$ qemu-system-x86_64 -display vnc=unix:/root/i-cant-access-you.sock
qemu-system-x86_64: iohandler.c:60: qemu_set_fd_handler2: Assertion `fd >= 0' failed.
Aborted (core dumped)

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ui/vnc.c

index 076355d9c5e2b20c524a64c99f726e23e2b351b9..fe4cd759a1e45cc3ffe21e81a96ad36b504bfb11 100644 (file)
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3684,6 +3684,9 @@ void vnc_display_open(const char *id, Error **errp)
         /* listen for connects */
         if (strncmp(vnc, "unix:", 5) == 0) {
             vs->lsock = unix_listen(vnc+5, NULL, 0, errp);
+            if (vs->lsock < 0) {
+                goto fail;
+            }
             vs->is_unix = true;
         } else {
             vs->lsock = inet_listen_opts(sopts, 5900, errp);