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

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