Blame SOURCES/0001-Read-MOSDocumentLockFile-UTF-16-string-data-with-sam.patch

1458e3
From 9f393ee10ae198063bbe3b71c2c87262e7880a34 Mon Sep 17 00:00:00 2001
1458e3
From: Stephan Bergmann <sbergman@redhat.com>
1458e3
Date: Wed, 23 Sep 2020 11:53:11 +0200
1458e3
Subject: [PATCH] Read MOSDocumentLockFile UTF-16 string data with same
1458e3
 endianness
1458e3
MIME-Version: 1.0
1458e3
Content-Type: text/plain; charset=UTF-8
1458e3
Content-Transfer-Encoding: 8bit
1458e3
1458e3
...as MSODocumentLockFile::WriteEntryToStream has written it to (i.e.,
1458e3
always as UTF-16LE, assuming that is actually the right format to use).  The
1458e3
discrepancy between writing and reading the string data appears to be present
1458e3
ever since the code's introduction in 5db1e20b8b0942dac2d50f3cd34532bb61147020
1458e3
"Introduce new lockfile handler for MSO like lockfiles".
1458e3
1458e3
This caused CppunitTest_svl_lockfiles to fail on (big-endian) s390x Linux with
1458e3
1458e3
> svl/qa/unit/lockfiles/test_lockfiles.cxx:578:(anonymous namespace)::LockfileTest::testWordLockFileRT
1458e3
> equality assertion failed
1458e3
> - Expected: LockFile Test
1458e3
> - Actual  : 䰀漀挀欀䘀椀氀攀 吀攀猀琀
1458e3
1458e3
etc.
1458e3
1458e3
Change-Id: I97267aa14a3a926e7fd7bb1d2ce7d2de05d52a64
1458e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103238
1458e3
Tested-by: Jenkins
1458e3
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
1458e3
(cherry picked from commit 1b9fa11a0869246fe0433b79aab30dd216cf92b6)
1458e3
---
1458e3
 svl/source/misc/msodocumentlockfile.cxx | 12 ++++++++++--
1458e3
 1 file changed, 10 insertions(+), 2 deletions(-)
1458e3
1458e3
diff --git a/svl/source/misc/msodocumentlockfile.cxx b/svl/source/misc/msodocumentlockfile.cxx
1458e3
index 9650db03999f..0c857ffb53ec 100644
1458e3
--- a/svl/source/misc/msodocumentlockfile.cxx
1458e3
+++ b/svl/source/misc/msodocumentlockfile.cxx
1458e3
@@ -228,8 +228,16 @@ LockFileEntry MSODocumentLockFile::GetLockData()
1458e3
                 nUTF16Len = *++pBuf; // use Excel/PowerPoint position
1458e3
 
1458e3
             if (nUTF16Len > 0 && nUTF16Len <= 52) // skip wrong format
1458e3
-                aResult[LockFileComponent::OOOUSERNAME]
1458e3
-                    = OUString(reinterpret_cast<const sal_Unicode*>(pBuf + 2), nUTF16Len);
1458e3
+            {
1458e3
+                OUStringBuffer str(nUTF16Len);
1458e3
+                sal_uInt8 const* p = reinterpret_cast<sal_uInt8 const*>(pBuf + 2);
1458e3
+                for (int i = 0; i != nUTF16Len; ++i)
1458e3
+                {
1458e3
+                    str.append(sal_Unicode(p[0] | (sal_uInt32(p[1]) << 8)));
1458e3
+                    p += 2;
1458e3
+                }
1458e3
+                aResult[LockFileComponent::OOOUSERNAME] = str.makeStringAndClear();
1458e3
+            }
1458e3
         }
1458e3
     }
1458e3
     return aResult;
1458e3
-- 
1458e3
2.33.1
1458e3