diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-09-03 21:07:00 +0200 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2018-09-10 17:45:01 +0200 |
commit | ec028a73aca92c9d16484d4803852526a1d845a1 (patch) | |
tree | 72dd7eb7f37af312512f3cb45fdcb3217ec55665 /sfx2/source | |
parent | 7218614a28237c19747eccd3954142c4e3e4ecc7 (diff) |
tdf#119381 sfx2 store: don't break symlink targets
osl::File::move() would not follow symlinks for the target, so don't
move the file in that case.
(cherry picked from commit 72be5ac08aa963bdd42d2e56a62f43e69f728caa)
Change-Id: I907e1ba8db04dad670c884ea0283947f953117da
Reviewed-on: https://gerrit.libreoffice.org/59982
Tested-by: Jenkins
Tested-by: Xisco Faulí <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 2e8b874deedb..e6a858ae6bf8 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -199,8 +199,8 @@ sal_uInt64 GetDefaultFileAttributes(const OUString& rURL) return nRet; } -/// Determines if rURL is a non-hard-linked file:// URL. -bool IsNotHardLinkedFile(const OUString& rURL) +/// Determines if rURL is a non-linked (symlink or hardlink) file:// URL. +bool IsNotLinkedFile(const OUString& rURL) { if (!comphelper::isFileUrl(rURL)) return false; @@ -211,10 +211,11 @@ bool IsNotHardLinkedFile(const OUString& rURL) return false; struct stat buf; - if (stat(rPath.toUtf8().getStr(), &buf) != 0) + if (lstat(rPath.toUtf8().getStr(), &buf) != 0) return false; - if (buf.st_nlink > 1) + // Hardlink or symlink: osl::File::move() doesn't play with these nicely. + if (buf.st_nlink > 1 || S_ISLNK(buf.st_mode)) return false; #endif @@ -1851,7 +1852,7 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL); - if (IsNotHardLinkedFile(aDestMainURL) && osl::File::move(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) + if (IsNotLinkedFile(aDestMainURL) && osl::File::move(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) { if (nAttributes) // Adjust attributes, source might be created with |