]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Address Coverity issues reported in bora/lib/file/file.c.
authorOliver Kurth <okurth@vmware.com>
Tue, 27 Aug 2019 19:55:37 +0000 (12:55 -0700)
committerOliver Kurth <okurth@vmware.com>
Tue, 27 Aug 2019 19:55:37 +0000 (12:55 -0700)
Fix a minor memory leak in the function File_ExpandAndCheckDir.
Also add annotations for unchecked return values in functions
GetOldMachineID and File_MoveTree, so that Coverity scans of
open-vm-tools will automatically classify these issues as
"Intentional".  These annotations are useful both for internal
use as well as for partners who run Coverity scans on open-vm-tools.

open-vm-tools/lib/file/file.c

index 7dae12c88673c8878c83005ad3d65212f771a905..774ec41981cd3158a35054cac2bd11c182122cce 100644 (file)
@@ -558,6 +558,7 @@ GetOldMachineID(void)
              sizeof hardwareID);
 
       /* Base 64 encode the binary data to obtain printable characters */
+      /* coverity[check_return] */
       Base64_Encode(rawMachineID, sizeof rawMachineID, encodedMachineID,
                     sizeof encodedMachineID, NULL);
 
@@ -1437,6 +1438,7 @@ File_MoveTree(const char *srcName,    // IN:
              * Only clean up if we created the directory.  Not attempting to
              * clean up partial failures.
              */
+            /* coverity[check_return] */
             File_DeleteDirectoryTree(dstName);
          }
       }
@@ -2186,6 +2188,7 @@ File_ExpandAndCheckDir(const char *dirName)  // IN:
 
          return edirName;
       }
+      free(edirName);
    }
 
    return NULL;