]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
[AppInfo] OVT Coverity fixes.
authorOliver Kurth <okurth@vmware.com>
Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)
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.

open-vm-tools/services/plugins/appInfo/appInfo.c

index 774ccae9eb6f79dfcb4231c7f4e62510c5a7c0df..d3209847514fa69ea7c0414b1e1cfc5c6bd33a2e 100644 (file)
@@ -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());