]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file: Posix FileLock_Lock pathName handling
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:53 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:53 +0000 (11:23 -0700)
Locking "/tmp" should create a lock "/tmp.lck".
Locking "tmp" should create a lock "./tmp.lck".

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

index fecfcaa289a3db488f9aa4bea50bd8b4f0d1cf43..1c1dc34c8cd68f2c976a35b5cee7b94094d29d80 100644 (file)
@@ -1060,7 +1060,6 @@ static char *
 FileLockNormalizePath(const char *filePath)  // IN:
 {
    char *result;
-   char *fullPath;
 
    char *dirName = NULL;
    char *fileName = NULL;
@@ -1074,12 +1073,25 @@ FileLockNormalizePath(const char *filePath)  // IN:
 
    File_GetPathName(filePath, &dirName, &fileName);
 
-   fullPath = File_FullPath(dirName);
+   /*
+    * Handle filePath - "xxx", "./xxx", "/xxx", and "/a/b/c".
+    */
+
+   if (*dirName == '\0') {
+      if (File_IsFullPath(filePath)) {
+         result = Unicode_Join(DIRSEPS, fileName, NULL);
+      } else {
+         result = Unicode_Join(".", DIRSEPS, fileName, NULL);
+      }
+   } else {
+      char *fullPath = File_FullPath(dirName);
 
-   result = (fullPath == NULL) ? NULL : Unicode_Join(fullPath, DIRSEPS,
-                                                     fileName, NULL);
+      result = (fullPath == NULL) ? NULL : Unicode_Join(fullPath, DIRSEPS,
+                                                        fileName, NULL);
+
+      Posix_Free(fullPath);
+   }
 
-   Posix_Free(fullPath);
    Posix_Free(dirName);
    Posix_Free(fileName);