From: Daniel P. Berrange Date: Mon, 2 Jun 2014 10:53:03 +0000 (+0100) Subject: libxl: Avoid possible use of uninitialized mem in libxlDomainStart X-Git-Tag: v1.2.6-rc1~204 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10a99a6d130b2266fa9b42073aad977abd7418c5;p=thirdparty%2Flibvirt.git libxl: Avoid possible use of uninitialized mem in libxlDomainStart The 'libxl_domain_config' object is stack allocated which means its memory contents are undefined. The libxl_domain_config_dispose() call is only safe if the memory is initialized to a defined state. Not all code paths which reach libxl_domain_config_dispose() will ensure that libxl_domain_config_init() is called. Move the libxl_domain_config_init() call earlier in the function to ensure all codepaths have defined memory state. Signed-off-by: Daniel P. Berrange --- diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index a1669801d9..eab789ac7f 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1100,6 +1100,8 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm, #endif virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr; + libxl_domain_config_init(&d_config); + if (libxlDomainObjPrivateInitCtx(vm) < 0) return ret; @@ -1149,8 +1151,6 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm, VIR_FREE(managed_save_path); } - libxl_domain_config_init(&d_config); - if (libxlBuildDomainConfig(driver->reservedVNCPorts, vm->def, priv->ctx, &d_config) < 0) goto endjob;