зеркало из https://github.com/mozilla/gecko-dev.git
Bug 936886 - Account for possibility of non-null terminated strings in nsWindowsRegKey::ReadStringValue(). r=dmajor
This commit is contained in:
Родитель
fd3ed78a40
Коммит
8d6c5dce65
|
@ -287,8 +287,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// |size| includes room for the terminating null character
|
||||
DWORD resultLen = size / 2 - 1;
|
||||
// |size| may or may not include the terminating null character.
|
||||
DWORD resultLen = size / 2;
|
||||
|
||||
result.SetLength(resultLen);
|
||||
nsAString::iterator begin;
|
||||
|
@ -299,6 +299,11 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
|||
rv = RegQueryValueExW(mKey, flatName.get(), 0, &type, (LPBYTE) begin.get(),
|
||||
&size);
|
||||
|
||||
if (!result.CharAt(resultLen-1)) {
|
||||
// The string passed to us had a null terminator in the final position.
|
||||
result.Truncate(resultLen-1);
|
||||
}
|
||||
|
||||
// Expand the environment variables if needed
|
||||
if (type == REG_EXPAND_SZ) {
|
||||
const nsString &flatSource = PromiseFlatString(result);
|
||||
|
|
Загрузка…
Ссылка в новой задаче