From a668429c31b93244d116e34e17c553b61e15ecc1 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 9 Sep 2015 14:49:58 +0200
Subject: [PATCH 5/8] vnc: Don't assert if opening unix socket fails

Message-id: <1441810198-32378-2-git-send-email-kraxel@redhat.com>
Patchwork-id: 67716
O-Subject: [RHEL-7.2 qemu-kvm-rhev PATCH 1/1] vnc: Don't assert if opening unix socket fails
Bugzilla: 1261263
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>

From: Cole Robinson <crobinso@redhat.com>

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>
(cherry picked from commit 3d00ac1a2ee0294fc3d460e6013a5cdd9c73ea6c)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 ui/vnc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui/vnc.c b/ui/vnc.c
index 3d3d960..c248ebc 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3697,6 +3697,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);
-- 
1.8.3.1

