File 53c9151b-Fix-xl-vncviewer-accesses-port-0-by-any-invalid-domid.patch of Package xen.1317

Subject: xl: 'xl vncviewer' accesses port 0 by any invalid domid
From: Chunyan Liu cyliu@suse.com Fri Jul 18 14:18:04 2014 +0800
Date: Fri Jul 18 13:37:47 2014 +0100:
Git: 2a8cc1a55329ead252ed323ec4bbee534d5c0f23

Currently, with command:
  xl vncviewer invalid_domid
it always brings user to the domU using vncport 5900.
The invalid domid could be an non-existing one or Dom0.
It's better to report error in this case.

Correct libxl_vncviewer_exec:
  In existing code, when vncport is NULL, it still continues
  and will show vncport 5900. So, with 'xl vncviewer 0' it also
  wrongly shows domU using vncport 5900. Correct it to report error
  if vncport is NULL.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>

Index: xen-4.4.3-testing/tools/libxl/libxl.c
===================================================================
--- xen-4.4.3-testing.orig/tools/libxl/libxl.c
+++ xen-4.4.3-testing/tools/libxl/libxl.c
@@ -1641,8 +1641,12 @@ int libxl_vncviewer_exec(libxl_ctx *ctx,
     vnc_port = libxl__xs_read(gc, XBT_NULL,
                             libxl__sprintf(gc,
                             "/local/domain/%d/console/vnc-port", domid));
-    if ( vnc_port )
-        port = atoi(vnc_port) - 5900;
+    if (!vnc_port) {
+        LOG(ERROR, "Cannot get vnc-port of domain %d", domid);
+        goto x_fail;
+    }
+
+    port = atoi(vnc_port) - 5900;
 
     vnc_listen = libxl__xs_read(gc, XBT_NULL,
                                 libxl__sprintf(gc,
openSUSE Build Service is sponsored by