Blame SOURCES/Do-not-listen-all-if-invalid-interface-is-provided.patch

9c8d8f
From bfa1432ea1972b4272e3a7b8927f7c22094e5e44 Mon Sep 17 00:00:00 2001
9c8d8f
From: Ondrej Holy <oholy@redhat.com>
9c8d8f
Date: Tue, 22 May 2018 21:06:06 +0200
9c8d8f
Subject: [PATCH 2/2] Do not listen all if invalid interface is provided
9c8d8f
9c8d8f
It is not a good idea from security point of view to listen all interfaces
9c8d8f
in case of invalid interface is provided. We should rather listen to nothing
9c8d8f
and print error in journal.
9c8d8f
9c8d8f
https://bugzilla.gnome.org/show_bug.cgi?id=796349
9c8d8f
---
9c8d8f
 server/libvncserver/sockets.c | 18 ++++++++++++------
9c8d8f
 server/vino-server.c          |  3 +++
9c8d8f
 2 files changed, 15 insertions(+), 6 deletions(-)
9c8d8f
9c8d8f
diff --git a/server/libvncserver/sockets.c b/server/libvncserver/sockets.c
9c8d8f
index 746a3e5..45df6d5 100644
9c8d8f
--- a/server/libvncserver/sockets.c
9c8d8f
+++ b/server/libvncserver/sockets.c
9c8d8f
@@ -152,9 +152,13 @@ rfbInitListenSock(rfbScreenInfoPtr rfbScreen)
9c8d8f
     char *netIface = (char*)rfbScreen->netIface;
9c8d8f
     int i;
9c8d8f
 
9c8d8f
-    if(netIface == NULL || if_nametoindex(netIface) == 0) {
9c8d8f
-      if(netIface != NULL)
9c8d8f
-        rfbLog("WARNING: This (%s) a invalid network interface, set to all\n", netIface);
9c8d8f
+    if(netIface != NULL && strlen(netIface) > 0) {
9c8d8f
+      if(if_nametoindex(netIface) == 0) {
9c8d8f
+        rfbLog("(%s) is an invalid network interface\n", netIface);
9c8d8f
+        return;
9c8d8f
+      }
9c8d8f
+    }
9c8d8f
+    else {
9c8d8f
       netIface = NULL;
9c8d8f
     }
9c8d8f
 
9c8d8f
@@ -748,9 +752,11 @@ rfbSetNetworkInterface(rfbScreenInfoPtr rfbScreen, const char *netIface)
9c8d8f
      rfbScreen->netIface = netIface;
9c8d8f
   }
9c8d8f
   else {
9c8d8f
-     rfbScreen->netIface = NULL;
9c8d8f
-     if(netIface != NULL)
9c8d8f
-        rfbLog("WARNING: This (%s) a invalid network interface, set to all\n", netIface);
9c8d8f
+    rfbScreen->netIface = NULL;
9c8d8f
+    if(netIface != NULL && strlen(netIface) > 0) {
9c8d8f
+      rfbLog("(%s) is an invalid network interface\n", netIface);
9c8d8f
+      return FALSE;
9c8d8f
+    }
9c8d8f
   }
9c8d8f
 
9c8d8f
   rfbLog("Re-binding socket to listen for VNC connections on TCP port %d in (%s) interface\n",
9c8d8f
diff --git a/server/vino-server.c b/server/vino-server.c
9c8d8f
index 38b17e3..b8cd755 100644
9c8d8f
--- a/server/vino-server.c
9c8d8f
+++ b/server/vino-server.c
9c8d8f
@@ -970,6 +970,9 @@ vino_server_init_io_channels(VinoServer *server)
9c8d8f
     {
9c8d8f
       dprintf (RFB, "%d ", rfb_screen->rfbListenSock[i]);
9c8d8f
 
9c8d8f
+      if (rfb_screen->rfbListenSock[i] == -1)
9c8d8f
+        continue;
9c8d8f
+
9c8d8f
       server->priv->io_channel[i] = g_io_channel_unix_new (rfb_screen->rfbListenSock[i]);
9c8d8f
       server->priv->io_watch[i]   = g_io_add_watch (server->priv->io_channel[i],
9c8d8f
                                                     G_IO_IN|G_IO_PRI,
9c8d8f
-- 
9c8d8f
2.17.0
9c8d8f