Backout 62dab36901e2 and 9b4445c0f202 (bug 1232458) for Windows bustage; r=me

This commit is contained in:
Nathan Froyd 2015-12-18 11:15:10 -05:00
parent 832e1be6b1
commit eef875bd6b

View File

@ -16,7 +16,6 @@
#include "nsAutoPtr.h"
#include "nsWindowsDllInterceptor.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/WindowsVersion.h"
#include "nsWindowsHelpers.h"
@ -479,8 +478,8 @@ DllBlockSet::Write(HANDLE file)
::LeaveCriticalSection(&sLock);
}
static UniquePtr<wchar_t[]>
getFullPath (PWCHAR filePath, wchar_t* fname)
static
wchar_t* getFullPath (PWCHAR filePath, wchar_t* fname)
{
// In Windows 8, the first parameter seems to be used for more than just the
// path name. For example, its numerical value can be 1. Passing a non-valid
@ -495,14 +494,14 @@ getFullPath (PWCHAR filePath, wchar_t* fname)
return nullptr;
}
auto full_fname = MakeUniqueFallible<wchar_t[]>(pathlen+1);
wchar_t* full_fname = new wchar_t[pathlen+1];
if (!full_fname) {
// couldn't allocate memory?
return nullptr;
}
// now actually grab it
SearchPathW(sanitizedFilePath, fname, L".dll", pathlen + 1, full_fname.get(),
SearchPathW(sanitizedFilePath, fname, L".dll", pathlen + 1, full_fname,
nullptr);
return full_fname;
}
@ -530,7 +529,7 @@ patched_LdrLoadDll (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileNam
int len = moduleFileName->Length / 2;
wchar_t *fname = moduleFileName->Buffer;
UniquePtr<wchar_t[]> full_fname;
nsAutoArrayPtr<wchar_t> full_fname;
// The filename isn't guaranteed to be null terminated, but in practice
// it always will be; ensure that this is so, and bail if not.
@ -653,23 +652,23 @@ patched_LdrLoadDll (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileNam
}
if (info->flags & DllBlockInfo::USE_TIMESTAMP) {
fVersion = GetTimestamp(full_fname.get());
fVersion = GetTimestamp(full_fname);
if (fVersion > info->maxVersion) {
load_ok = true;
}
} else {
DWORD zero;
DWORD infoSize = GetFileVersionInfoSizeW(full_fname.get(), &zero);
DWORD infoSize = GetFileVersionInfoSizeW(full_fname, &zero);
// If we failed to get the version information, we block.
if (infoSize != 0) {
auto infoData = MakeUnique<unsigned char[]>(infoSize);
nsAutoArrayPtr<unsigned char> infoData(new unsigned char[infoSize]);
VS_FIXEDFILEINFO *vInfo;
UINT vInfoLen;
if (GetFileVersionInfoW(full_fname.get(), 0, infoSize, infoData.get()) &&
VerQueryValueW(infoData.get(), L"\\", (LPVOID*) &vInfo, &vInfoLen))
if (GetFileVersionInfoW(full_fname, 0, infoSize, infoData) &&
VerQueryValueW(infoData, L"\\", (LPVOID*) &vInfo, &vInfoLen))
{
fVersion =
((unsigned long long)vInfo->dwFileVersionMS) << 32 |
@ -705,7 +704,7 @@ continue_loading:
return STATUS_DLL_NOT_FOUND;
}
if (IsVistaOrLater() && !CheckASLR(full_fname.get())) {
if (IsVistaOrLater() && !CheckASLR(full_fname)) {
printf_stderr("LdrLoadDll: Blocking load of '%s'. XPCOM components must support ASLR.\n", dllName);
return STATUS_DLL_NOT_FOUND;
}