From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:30 +0000 (-0700) Subject: Fixed invalid class pointer access if VSS provider not installed X-Git-Tag: stable-10.2.0~298 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7886e7a44582fbc019e995afa2147eb0efd6710;p=thirdparty%2Fopen-vm-tools.git Fixed invalid class pointer access if VSS provider not installed Some customers may disable VSS support by not installing VMware snapshot provider, which may lead to the VSS provider not being able to be initialized, which in turn could lead to a invalid class pointer access during complete initialization. This change checks provider initialization status before initialize completer to fix the issue. --- diff --git a/open-vm-tools/services/plugins/vmbackup/stateMachine.c b/open-vm-tools/services/plugins/vmbackup/stateMachine.c index 2a7b16df7..5f530dd2f 100644 --- a/open-vm-tools/services/plugins/vmbackup/stateMachine.c +++ b/open-vm-tools/services/plugins/vmbackup/stateMachine.c @@ -86,6 +86,8 @@ VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING); #define VMBACKUP_CONFIG_GET_INT(config, key, defVal) \ VMTools_ConfigGetInteger(config, "vmbackup", key, defVal) +#define VMBACKUP_CFG_ENABLEVSS "enableVSS" + static VmBackupState *gBackupState = NULL; static Bool @@ -871,7 +873,7 @@ VmBackupStartCommon(RpcInData *data, const gchar *cfgEntry; } providers[] = { #if defined(_WIN32) - { VmBackup_NewVssProvider, "enableVSS" }, + { VmBackup_NewVssProvider, VMBACKUP_CFG_ENABLEVSS}, #endif { VmBackup_NewSyncDriverProvider, "enableSyncDriver" }, { VmBackup_NewNullProvider, NULL }, @@ -884,8 +886,17 @@ VmBackupStartCommon(RpcInData *data, * only allow VSS provider */ #if defined(_WIN32) - if (VMBACKUP_CONFIG_GET_BOOL(ctx->config, "enableVSS", TRUE)) { + if (VMBACKUP_CONFIG_GET_BOOL(ctx->config, + VMBACKUP_CFG_ENABLEVSS, TRUE)) { provider = VmBackup_NewVssProvider(); + if (provider != NULL) { + completer = VmBackup_NewVssCompleter(provider); + if (completer == NULL) { + g_warning("VSS completion helper cannot be initialized."); + provider->release(provider); + provider = NULL; + } + } } #elif defined(_LINUX) || defined(__linux__) /* @@ -901,10 +912,6 @@ VmBackupStartCommon(RpcInData *data, /* If no quiescing is requested only allow null provider */ provider = VmBackup_NewNullProvider(); } - if (provider == NULL) { - g_warning("Requested quiescing cannot be initialized."); - goto error; - } } else { /* Instantiate the sync provider. */ for (i = 0; i < ARRAYSIZE(providers); i++) { @@ -913,24 +920,30 @@ VmBackupStartCommon(RpcInData *data, if (VMBACKUP_CONFIG_GET_BOOL(ctx->config, sp->cfgEntry, TRUE)) { provider = sp->ctor(); if (provider != NULL) { +#if defined(_WIN32) + if (sp->cfgEntry != NULL && + Str_Strcmp(sp->cfgEntry, VMBACKUP_CFG_ENABLEVSS) == 0) { + completer = VmBackup_NewVssCompleter(provider); + if (completer == NULL) { + g_warning("VSS completion helper cannot be initialized."); + provider->release(provider); + provider = NULL; + continue; + } + break; + } +#else break; +#endif } } } } - ASSERT(provider != NULL); - -#if defined(_WIN32) - if (VMBACKUP_CONFIG_GET_BOOL(ctx->config, "enableVSS", TRUE)) { - completer = VmBackup_NewVssCompleter(provider); - if (completer == NULL) { - provider->release(provider); - g_warning("Requested quiescing cannot be initialized."); - goto error; - } + if (provider == NULL) { + g_warning("Requested quiescing cannot be initialized."); + goto error; } -#endif /* Instantiate the backup state and start the operation. */ gBackupState->ctx = data->appCtx;