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

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