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 <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2014-06-02 11:53:03 +01:00
parent 3bab69c30f
commit 10a99a6d13

View File

@ -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;