]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commit
xl: Sane handling of extra config file arguments
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 15 Jun 2015 13:50:42 +0000 (14:50 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 7 Jul 2015 15:56:30 +0000 (16:56 +0100)
commitdd84604f35bd3855c57146eb8fe53924c10d3963
tree4f4b372454e92bdf6451a48c3b21d6eec331b412
parent9acfbe14d7261b03e3b3f4dc3c850ba2a7093e1f
xl: Sane handling of extra config file arguments

Various xl sub-commands take additional parameters containing = as
additional config fragments.

The handling of these config fragments has a number of bugs:

 1. Use of a static 1024-byte buffer.  (If truncation would occur,
    with semi-trusted input, a security risk arises due to quotes
    being lost.)

 2. Mishandling of the return value from snprintf, so that if
    truncation occurs, the to-write pointer is updated with the
    wanted-to-write length, resulting in stack corruption.  (This is
    XSA-137.)

 3. Clone-and-hack of the code for constructing the appended
    config file.

These are fixed here, by introducing a new function
`string_realloc_append' and using it everywhere.  The `extra_info'
buffers are replaced by pointers, which start off NULL and are
explicitly freed on all return paths.

The separate variable which will become dom_info.extra_config is
abolished (which involves moving the clearing of dom_info).

Additional bugs I observe, not fixed here:

 4. The functions which now call string_realloc_append use ad-hoc
    error returns, with multiple calls to `return'.  This currently
    necessitates multiple new calls to `free'.

 5. Many of the paths in xl call exit(-rc) where rc is a libxl status
    code.  This is a ridiculous exit status `convention'.

 6. The loops for handling extra config data are clone-and-hacks.

 7. Once the extra config buffer is accumulated, it must be combined
    with the appropriate main config file.  The code to do this
    combining is clone-and-hacked too.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Tested-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian,campbell@citrix.com>
tools/libxl/xl_cmdimpl.c