]> xenbits.xensource.com Git - xen.git/commitdiff
libxc: fix segfault on uninitialized xch->fmem
authorSeraphime Kirkovski <kirkseraph@gmail.com>
Tue, 4 Apr 2017 12:40:48 +0000 (14:40 +0200)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 16 May 2017 14:42:51 +0000 (15:42 +0100)
Currently in xc_interface_open, xch->fmem is not initialized
and in some rare case the code fails before ever assigning a value
to it.

I got this in master:

   $ sudo ./xl/xl run
   xencall: error: Could not obtain handle on privileged command interface: No such file or directory
   Segmentation fault

This initializes the whole xch_buff to 0.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
(cherry picked from commit c4bdbec00c9063736361124a3492ebceabfaed06)
(cherry picked from commit efd2ff999df72ee4c246927fd4297e3a75cadbf3)
(cherry picked from commit 6a689975c69a38eb53c3de0b533a3d985dc8431d)

tools/libxc/xc_private.c

index 7c398974fe82b24c8ba436f409453c2d1cec7d9e..dba673e5b38a611b643c17faa01372e737f7c802 100644 (file)
@@ -131,7 +131,7 @@ static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *log
                                                           unsigned open_flags,
                                                           enum xc_osdep_type type)
 {
-    struct xc_interface_core xch_buf, *xch = &xch_buf;
+    struct xc_interface_core xch_buf = { 0 }, *xch = &xch_buf;
 
     xch->type = type;
     xch->flags = open_flags;