From: Oliver Kurth Date: Mon, 23 Oct 2017 21:21:18 +0000 (-0700) Subject: lib/file: FileIO_AtomicUpdateEx ASSERT X-Git-Tag: stable-10.3.0~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7ee5608972cdb7a585fb7b1a13fb62f24f546e9;p=thirdparty%2Fopen-vm-tools.git lib/file: FileIO_AtomicUpdateEx ASSERT ASSERT(File_IsSameFile(dirName, dstDirName)) fired when NFS went down at just the right moment. It was not obvious that the ASSERT fired due to an NFS failure. File_IsSameFile correctly returns errno upon failure. Check the errno value to properly detect and return an error. --- diff --git a/open-vm-tools/lib/file/fileIO.c b/open-vm-tools/lib/file/fileIO.c index 1c3657235..b053ed232 100644 --- a/open-vm-tools/lib/file/fileIO.c +++ b/open-vm-tools/lib/file/fileIO.c @@ -854,6 +854,7 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor char *fileName = NULL; char *dstDirName = NULL; char *dstFileName = NULL; + Bool isSame; currPath = File_FullPath(FileIO_Filename(currFD)); if (currPath == NULL) { @@ -875,10 +876,19 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor File_GetPathName(currPath, &dstDirName, &dstFileName); ASSERT(dirName != NULL); - ASSERT(fileName && *fileName); + ASSERT(fileName != NULL && *fileName != '\0'); ASSERT(dstDirName != NULL); - ASSERT(dstFileName && *dstFileName); - ASSERT(File_IsSameFile(dirName, dstDirName)); + ASSERT(dstFileName != NULL && *dstFileName != '\0'); + + errno = 0; + isSame = File_IsSameFile(dirName, dstDirName); + if (errno == 0) { + ASSERT(isSame); + } else { + savedErrno = errno; + Log("%s: File_IsSameFile failed (errno = %d).\n", __FUNCTION__, errno); + goto swapdone; + } args = Util_SafeCalloc(1, sizeof *args); args->fd = currFD->posix; @@ -1027,7 +1037,7 @@ swapdone: * * FileIO_AtomicUpdate -- * - * Wrapper around FileIO_AtomicUpdateEx that derfaults 'renameOnNFS' to + * Wrapper around FileIO_AtomicUpdateEx that defaults 'renameOnNFS' to * TRUE. * * Results: