Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 4fa18c2

Browse files
committed
Bug 1700870 - Explicitly convert path to UTF-8. r=application-update-reviewers,bytesized
nsPrintfCString %S converts from UTF-16 to the ANSI code page, but we rely on the output string being UTF-8. Differential Revision: https://phabricator.services.mozilla.com/D110355
1 parent 1895a73 commit 4fa18c2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

toolkit/xre/MultiInstanceLock.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ static bool GetLockFileName(const char* nameToken, const char16_t* installPath,
4040
mozilla::UniquePtr<wchar_t, CoTaskMemFreeDeleter> programDataPathUnique(
4141
programDataPath);
4242

43-
filePath = nsPrintfCString("%S\\%s\\%s-%S", programDataPath, MOZ_APP_VENDOR,
44-
nameToken, pathHash.get());
43+
filePath = nsPrintfCString(
44+
"%s\\%s\\%s-%s", NS_ConvertUTF16toUTF8(programDataPath).get(),
45+
MOZ_APP_VENDOR, nameToken, NS_ConvertUTF16toUTF8(pathHash.get()).get());
4546

4647
#else
4748
// On POSIX platforms the base path is /tmp/[vendor][nameToken]-[pathHash].
@@ -56,7 +57,9 @@ static bool GetLockFileName(const char* nameToken, const char16_t* installPath,
5657
MultiInstLockHandle OpenMultiInstanceLock(const char* nameToken,
5758
const char16_t* installPath) {
5859
nsCString filePath;
59-
GetLockFileName(nameToken, installPath, filePath);
60+
if (!GetLockFileName(nameToken, installPath, filePath)) {
61+
return MULTI_INSTANCE_LOCK_HANDLE_ERROR;
62+
}
6063

6164
// Open a file handle with full privileges and sharing, and then attempt to
6265
// take a shared (nonexclusive, read-only) lock on it.

0 commit comments

Comments
 (0)