diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-10-15 20:34:28 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-10-16 19:54:13 +0200 |
commit | 872f363a5926c76ed8b21dc209352cebfe955764 (patch) | |
tree | 646c617c8a4339fb06ee7458405d9536e14c7828 /sal/osl/unx | |
parent | 5d0c83fd4cf91083805f60f49e4fafd3d6ac73d4 (diff) |
Avoid risk of looking at an errno modified by SAL_INFO() call
Thanks to Stephan for noticing.
Change-Id: I6b90258bdc6bce7b2aeb44f9a1a136b4b9bd51c9
Reviewed-on: https://gerrit.libreoffice.org/61812
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sal/osl/unx')
-rw-r--r-- | sal/osl/unx/file.cxx | 7 | ||||
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index c3c5cd7fd655..ae1bc31c9069 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -966,7 +966,10 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, sal_uI int e = errno; SAL_INFO("sal.file", "flock(" << fd << ",LOCK_EX|LOCK_NB): errno " << e << ": " << strerror(e)); /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */ - if ((e != ENOTSUP) || ((flock(fd, LOCK_SH | LOCK_NB) == 1) && (errno != ENOTSUP))) + + // Restore errno after possibly having been overwritten by the SAL_INFO above... + errno = e; + if ((errno != ENOTSUP) || ((flock(fd, LOCK_SH | LOCK_NB) == 1) && (errno != ENOTSUP))) { eRet = oslTranslateFileError(errno); (void) close(fd); @@ -1100,7 +1103,7 @@ oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle) { int e = errno; SAL_INFO("sal.file", "fsync(" << pImpl->m_fd << "): errno " << e << ": " << strerror(e)); - return oslTranslateFileError(errno); + return oslTranslateFileError(e); } else SAL_INFO("sal.file", "fsync(" << pImpl->m_fd << "): OK"); diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index 507779c7fe6c..a45d32e4c79e 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -218,6 +218,8 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirect { int e = errno; SAL_INFO("sal.file", "opendir(" << path << "): errno " << e << ": " << strerror(e)); + // Restore errno after possible modification by SAL_INFO above + errno = e; } } } @@ -249,7 +251,7 @@ oslFileError SAL_CALL osl_closeDirectory(oslDirectory pDirectory) { int e = errno; SAL_INFO("sal.file", "closedir(" << pDirImpl->pDirStruct << "): errno " << e << ": " << strerror(e)); - err = oslTranslateFileError(errno); + err = oslTranslateFileError(e); } else SAL_INFO("sal.file", "closedir(" << pDirImpl->pDirStruct << "): OK"); @@ -819,7 +821,7 @@ static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* int e = errno; SAL_INFO("sal.file", "rename(" << pszDestFileName << ", " << tmpDestFile << "): errno " << e << ": " << strerror(e)); - if (errno == ENOENT) + if (e == ENOENT) { DestFileExists = 0; } |