]> xenbits.xensource.com Git - people/iwj/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:41:56 +0000 (15:41 +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)

tools/libxc/xc_private.c

index 9ba4b73229b14d9c06e459a831037824a937cc8b..7bea1c555d11d6fb0f9c86ed40ce9cd2bb8999a2 100644 (file)
@@ -30,7 +30,7 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger,
                                             xentoollog_logger *dombuild_logger,
                                             unsigned open_flags)
 {
-    struct xc_interface_core xch_buf, *xch = &xch_buf;
+    struct xc_interface_core xch_buf = { 0 }, *xch = &xch_buf;
 
     xch->flags = open_flags;
     xch->dombuild_logger_file = 0;