From: Katy Feng Date: Thu, 16 Nov 2023 17:21:20 +0000 (-0800) Subject: Fix double free in guestInfoServer.c. X-Git-Tag: stable-12.4.0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f7374c8ab89c546e4e32d3302442103c0a0ba5e;p=thirdparty%2Fopen-vm-tools.git Fix double free in guestInfoServer.c. Double free in "GuestInfoGather(gpointer data)" for osNameFullOverride. --- diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 9077e6b3e..8ec1236e3 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -543,7 +543,7 @@ GuestInfoGather(gpointer data) int maxIPv4RoutesToGather; int maxIPv6RoutesToGather; gchar *osNameOverride; - gchar *osNameFullOverride; + gchar *osNameFullOverride = NULL; Bool maxNicsError = FALSE; static uint32 logThrottleCount = 0; Bool sendOsNames = FALSE; @@ -570,19 +570,15 @@ GuestInfoGather(gpointer data) CONFGROUPNAME_GUESTOSINFO, CONFNAME_GUESTOSINFO_SHORTNAME, NULL); - - osNameFullOverride = VMTools_ConfigGetString(ctx->config, - CONFGROUPNAME_GUESTOSINFO, - CONFNAME_GUESTOSINFO_LONGNAME, - NULL); - /* If only the OS Full Name is provided, continue as normal, but emit - * warning. */ - if (osNameOverride == NULL && osNameFullOverride != NULL) { - g_warning("Ignoring " CONFNAME_GUESTOSINFO_LONGNAME " override.\n"); - g_warning("To use the GOS name override, " - CONFNAME_GUESTOSINFO_SHORTNAME " must be present in the " - "tools.conf file.\n"); - g_free(osNameFullOverride); + /* + * CONFNAME_GUESTINFO_LONGNAME is ignored if CONFNAME_GUESTINFO_SHORTNAME + * is not provided + */ + if (osNameOverride) { + osNameFullOverride = VMTools_ConfigGetString(ctx->config, + CONFGROUPNAME_GUESTOSINFO, + CONFNAME_GUESTOSINFO_LONGNAME, + NULL); } /* Gather all the relevant guest information. */ diff --git a/open-vm-tools/tools.conf b/open-vm-tools/tools.conf index 9a70c2d05..64cb844bd 100644 --- a/open-vm-tools/tools.conf +++ b/open-vm-tools/tools.conf @@ -359,7 +359,7 @@ # Override the short OS name sent by tools. #short-name= -# Override the long OS name sent by tools. +# Override the long OS name sent by tools. Ignored if short-name is not set. #long-name= [vmbackup]