Backout 6a9d0f869621 (bug 1232458) for adding inappropriate colors to our CLOSED TREE
authorNathan Froyd <froydnj@mozilla.com>
Thu, 24 Dec 2015 21:45:30 -0500
changeset 317678 691f2e687e46d1b166b88b0a3f9dbd480bff9afa
parent 317677 acdd7908ca0ff345c509dd9e2c0395bb00277289
child 317705 3c5e7567281ff6d6fe43726bd65923165458abc4
child 317738 130f9741f78043db6f6864ec61cf097bd90b8559
push id8746
push userananuti@gmail.com
push dateSun, 27 Dec 2015 23:03:33 +0000
bugs1232458
milestone46.0a1
backs out6a9d0f8696218fe9d5b7805a1d800e28166b67a0
Backout 6a9d0f869621 (bug 1232458) for adding inappropriate colors to our CLOSED TREE
mozglue/build/WindowsDllBlocklist.cpp
--- a/mozglue/build/WindowsDllBlocklist.cpp
+++ b/mozglue/build/WindowsDllBlocklist.cpp
@@ -11,17 +11,16 @@
 #pragma warning( disable : 4275 4530 ) // See msvc-stl-wrapper.template.h
 #include <map>
 #pragma warning( pop )
 
 #define MOZ_NO_MOZALLOC
 #include "nsAutoPtr.h"
 
 #include "nsWindowsDllInterceptor.h"
-#include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/WindowsVersion.h"
 #include "nsWindowsHelpers.h"
 
 using namespace mozilla;
 
 #define ALL_VERSIONS   ((unsigned long long)-1LL)
 
 // DLLs sometimes ship without a version number, particularly early
@@ -474,40 +473,40 @@ DllBlockSet::Write(HANDLE file)
       WriteFile(file, ";", 1, &nBytes, nullptr);
     }
   }
   MOZ_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { }
 
   ::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
   // pointer to SearchPathW will cause a crash, so we need to check to see if we
   // are handed a valid pointer, and otherwise just pass nullptr to SearchPathW.
   PWCHAR sanitizedFilePath = (intptr_t(filePath) < 4096) ? nullptr : filePath;
 
   // figure out the length of the string that we need
   DWORD pathlen = SearchPathW(sanitizedFilePath, fname, L".dll", 0, nullptr,
                               nullptr);
   if (pathlen == 0) {
     return nullptr;
   }
 
-  UniquePtr<wchar_t[]> full_fname(new (std::nothrow) 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;
 }
 
 // No builtin function to find the last character matching a set
 static wchar_t* lastslash(wchar_t* s, int len)
 {
   for (wchar_t* c = s + len - 1; c >= s; --c) {
@@ -525,17 +524,17 @@ patched_LdrLoadDll (PWCHAR filePath, PUL
 #define DLLNAME_MAX 128
   char dllName[DLLNAME_MAX+1];
   wchar_t *dll_part;
   char *dot;
   DllBlockInfo *info;
 
   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.
   // This is done instead of the more robust approach because of bug 527122,
   // where lots of weird things were happening when we tried to make a copy.
   if (moduleFileName->MaximumLength < moduleFileName->Length+2 ||
       fname[len] != 0)
   {
@@ -648,33 +647,33 @@ patched_LdrLoadDll (PWCHAR filePath, PUL
       full_fname = getFullPath(filePath, fname);
       if (!full_fname) {
         // uh, we couldn't find the DLL at all, so...
         printf_stderr("LdrLoadDll: Blocking load of '%s' (SearchPathW didn't find it?)\n", dllName);
         return STATUS_DLL_NOT_FOUND;
       }
 
       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 |
               ((unsigned long long)vInfo->dwFileVersionLS);
 
             // finally do the version check, and if it's greater than our block
             // version, keep loading
             if (fVersion > info->maxVersion)
@@ -700,17 +699,17 @@ continue_loading:
     // Check to ensure that the DLL has ASLR.
     full_fname = getFullPath(filePath, fname);
     if (!full_fname) {
       // uh, we couldn't find the DLL at all, so...
       printf_stderr("LdrLoadDll: Blocking load of '%s' (SearchPathW didn't find it?)\n", dllName);
       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;
     }
   }
 
   return stub_LdrLoadDll(filePath, flags, moduleFileName, handle);
 }