From: Oliver Kurth Date: Mon, 9 Sep 2019 18:23:49 +0000 (-0700) Subject: [AppInfo] OVT Coverity fixes. X-Git-Tag: stable-11.1.0~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2668aedffce69784b29da9bc951492dc5657840;p=thirdparty%2Fopen-vm-tools.git [AppInfo] OVT Coverity fixes. The return value of Str_Snprintf is not being checked for negative values and is directly passed to DynBuf_Append which accepts only positive values. This may cause issues if Str_Snprintf fails. Added a trivial check. Initialized appList variable to NULL. --- diff --git a/open-vm-tools/services/plugins/appInfo/appInfo.c b/open-vm-tools/services/plugins/appInfo/appInfo.c index 774ccae9e..d32098475 100644 --- a/open-vm-tools/services/plugins/appInfo/appInfo.c +++ b/open-vm-tools/services/plugins/appInfo/appInfo.c @@ -205,7 +205,7 @@ AppInfoGatherTask(ToolsAppCtx *ctx, gchar *tstamp = NULL; char *escapedCmd = NULL; char *escapedVersion = NULL; - GSList *appList; + GSList *appList = NULL; GSList *appNode; static Atomic_uint64 updateCounter = {0}; uint64 counter = (uint64) Atomic_ReadInc64(&updateCounter) + 1; @@ -228,12 +228,16 @@ AppInfoGatherTask(ToolsAppCtx *ctx, tstamp = VMTools_GetTimeAsString(); - len = Str_Snprintf(tmpBuf, sizeof tmpBuf, headerFmt, APP_INFO_VERSION_1, counter, tstamp != NULL ? tstamp : ""); + if (len < 0) { + g_warning("Insufficient space for the header.\n"); + goto abort; + } + DynBuf_Append(&dynBuffer, tmpBuf, len); appList = AppInfo_SortAppList(AppInfo_GetAppList());