]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
tools: Fix Coverity errors in resolution plugin.
authorJohn Wolfe <jwolfe@vmware.com>
Wed, 23 Dec 2020 15:33:50 +0000 (07:33 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Wed, 23 Dec 2020 15:33:50 +0000 (07:33 -0800)
Fix multiplication overflow and fgetc usage to avoid Coverity errors.

open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c
open-vm-tools/services/plugins/resolutionSet/resolutionX11.c

index 668924850ea62f49c6fb03819af939eba5cf07a5..574e004ac9aefc3a23fb7d30978409251518f07f 100644 (file)
@@ -400,7 +400,7 @@ resolutionXorgDriverVersion(int numPaths,               // IN: Number of strings
 {
    FILE *driver = NULL;
    const char *curMatch;
-   char curFileChar;
+   int curFileChar;
    int i;
 
    g_debug("%s: Scanning for VMWare Xorg drivers.\n", __func__);
@@ -423,7 +423,7 @@ resolutionXorgDriverVersion(int numPaths,               // IN: Number of strings
         goto outNotFound;
 
       curFileChar = fgetc(driver);
-      if (curFileChar == *curMatch) {
+      if (curFileChar != EOF && curFileChar == *curMatch) {
         curMatch++;
         continue;
       } else if (curMatch != versionString) {
index c5591139d07fad22c35ac2b65dcbf7fa7d5103b8..63b5812c9695daeca70d119811f5689383500d40 100644 (file)
@@ -533,7 +533,7 @@ SelectResolution(uint32 width,
     * and height.
     */
    for (i = 0; i < xrrNumSizes; i++) {
-      potentialSize = xrrSizes[i].width * xrrSizes[i].height;
+      potentialSize = (uint64)xrrSizes[i].width * xrrSizes[i].height;
       if (xrrSizes[i].width <= width && xrrSizes[i].height <= height &&
           potentialSize > bestFitSize ) {
          bestFitSize = potentialSize;